Where should i store score variable? - unreal-engine4

I'm working on my multiplayer game. The game is about pvp, you can shoot your friends and all stuff like that. I decided to make a score widget, which would show who is better. You might have seen something similar to what I'm talking about in fps games like csgo, valorant, overwatch, etc. Everyone should see the score.
I tried storing variables on servers character pawn. But pawn can be destroyed and score rollbacks to 0:0.

For replicated data that is persistent to respawn, you have two main options with the built-in game framework:
Create your own subclass of AGameState and the replicated data you want in it. There is one Game state and it is replicated on all clients. See what the official wiki (bottom of the page) says about GameState. You can store game-related data in it as total kill count in team deathmatches or team capture points in domination matches.
Create your own subclass of APlayerState and the replicated data you want in it. There is one Player state per player and it is replicated on all clients. See the official API of APlayerState. You can store each players' kill count in it for example or the number of objective a player captured. Make sure data is fed from the server and replicated to clients and not the other way around.
Unreal Engine comes with a powerful Game Framework, make sure to get familiar with it.

Related

How to count individual scores in game with multiple players?

I am running program that takes interactions from viewers of my live and uses their profile pictures as textures on primitive cubes that spawn after they interact (such as sending likes). I have gotten as far as recieving the usernames of those interacting with my live, and I am now trying to create a score board to keep track of the amount of primitive cubes each user spawns by interacting. I am curious if it is possible to track peoples individual score by filtering through their usernames.
As an example, say "Adam.01" interacts 2 times with the live. I will recieve his username and profile picture on Unity and my script creates 2 primitive cubes with his profile picture on them. My goal is for every cube that spawns, a score keeper specifically under "Adam.01"'s username will add 2 to his "total score" as he now has 2 primitive cubes.
Sorry if I'm struggling to explain what my goal is, its kinda a wacky idea but Im having fun with my stream and trying to stay creative. Thanks!

Architecture: Creating a time filterable leaderboard system with mongoose

This question is more of a architecture based one.
I have a website which has 3 PVP (player vs player) games. Each game has it's own mongoDB collection
and it's documents have properties such as timestamp, amount won (points) and players involved.
I want to create a leaderboard system that retrieves data from all these 3 games, and shows who has won the most in a top 10 kind of style. This system will be accessed most likely through a HTTP end point. And I'd also like this leaderboard to be filterable by time: top 10 from the last week/month/year/all time
Problems:
As the user database has grown and more games have been created, Computing the table each time the end point is hit takes longer and longer. Page load times take a super long.
Initial Idea
Technologies
Mongoose, Express, Nuxt(Vue), Socket.io
I would suggest some sort of caching scheme. Two basic method I would consider:
Create a service that automatically tabulates the leaderboard and caches it or saves it to another mongo object. Clients are then served the cached version. This option is nice as it creates a historical record which could make for fun features in the future.
Cache the response in your express service and update it only on some frequency. As explained here: https://medium.com/the-node-js-collection/simple-server-side-cache-for-express-js-with-node-js-45ff296ca0f0 The risk with this method is if you have concurrent requests when the leaderboard is being generated it could hit your mongo server hard.
Without knowing all the details, I would go with the first option as it is immune to concurrent requests and could be extended in the future with some sort of historical leaderboard feature.
As for filtering, I'd recommend using the tables in vue-bootstrap. Data is easily represented in tables and sorting is built-in.

Can cloud firestore realistically be used for syncing a game between players?

I'm looking at using cloud firestore to sync a multiplayer web game between players. However, this game involves continuous motion, like a player dragging a piece from one place to another. This would involve a stream of writes as its position changes. Given that the free plan is 20k free writes per day, and 20k writes can be done by a dozen players in a few minutes in this case, I worry that the cost would rapidly spiral out of control.
Is it impossible to do this sort of thing with firestore? I'm basically talking about a continuous websocket connection keeping the game data synced between players.
The limits of Firestore are well-documented. You haven't really said what hard limits you're concerned about exceeding. The only thing you've indicated is limits regarding the perpetual free tier, which can be easily exceeded by simply paying for the product based on your usage.
If you're not willing to pay for the service based on your needs, then you should probably look for another service. If you are willing to pay, then you need to do the math to figure out what your specific needs are, and if they can be met by the documented limits.
In the absence of more specific information about what you're trying to achieve, there's not much else that can be said.

way to allocate more than 1000 achievement points?

Is there a way to request or allocate more than 1000 achievement points for your application?
The issue here is that I am developing a game and plan to have regular content pack expansions. Along with those expansions, I want to include new achievements relating to whatever new content is included.
My initial plan was to simply reduce the value for each achievement, say 1pt for easy, 3 for medium, 5 for difficult and just keep utilizing the 1000 point pool as slowly as I could. Obviously, this wouldn't solve the problem, but it'd be a decent compromise.
However, after reading the description of how the achievements work at https://developers.facebook.com/docs/achievements/ I'd rather not hamstring my application by utilizing point values that will not be distributed.
So, does anyone know of a way to overcome this limitation?
Based on the documentation I've read (which includes the URL you provided) you can not exceed 1000 points allocated to any given player. So there is no reason why you can't launch new content packs with new achievements, it's just that you won't be able to allocate any of them to any players (or won't get any distribution within Facebook if you do) for any players who have already achieved their lifetime maximum of 1000 points with your app. If you design your gameplay mechanics so that you essentially have to achieve every previous achievement to reach the latest one, then it means that eventually, additional content packs you publish won't be publishable to facebook via the Achievements API.
So, to your first question, no there is no way to request or allocate more than 1000 achievement points for your application for a given user.
To your second question, make sure you've read the achievements section of this page:
https://developers.facebook.com/docs/guides/games/growth/
Here they talk about how much distribution you get for the number of points you allocate to each achievement. If the goal is to maximize your distribution, then you need to design your game around achievements that put at least a 100 point value on your game's most notable achievements. If you choose 5 of these because you plan to have five content pack expansions, and you want your app to continue to push notifications for your players who have played all five, you need to consider allocating a maximum of 500 points to the other tiers of achievement distribution tiers.
So ultimately, this is a task that balances the achievements you have in the game with the amount of distribution you want to get in Facebook, and that each player in the game has a LTV associated with this API that once you hit 1000 represents little value to you to promote via the Achievements API beyond that point.
If you design your game such that achievements aren't linear, and if people can play the latest content packs without completing the previous ones, then newer players can publish new achievements that older players who have already achieved 1000 points worth won't be able to.
EDIT: Also consider this blog post, which indicates that Facebook seems to want to have all the achievements defined up-front to show the "you've accomplished 1 of n accomplishments so far" kind of progress:
http://devgotchas.grgventures.com/node/9

XMPP multiplayer gaming: should I store opponents as roster contacts?

I've read all 484 pages of Professional XMPP and read countless forum threads regarding rosters + XMPP and this question is still something I am struggling to solve. I'm looking for insight on best practices, so I at least know which direction to go in.
I'm building a cross-platform (web, iOS & Xbox), turn-based board game. Every player can have up to 100 different matches active at any given moment -- so they could easily skip from one game where it's not there turn to one where it is.
The game will feature a lobby where your list of active games are displayed, along with the name and online status of each opponent for that game (you may have up to 3 opponents, 4 total players per game).
Additionally, each player will have a friends list accessible from a different area which also lists online status.
I am using XMPP behind the scenes, completely transparent to the players, no one will ever sign in with a Jabber client or anything of the sort. I have complete control over how the information is displayed and utilized.
The main aspects I am using XMPP to solve are: notifications when an opponent has made a move, seeing my friends online statuses, and seeing my opponents online statuses, and in-game text chat.
So here's where I start having trouble: obviously your friends list will be contacts in your roster, so you can see their online status. But what about opponents? These are usually random opponents you will only play a single match with and never again -- yet your game with them may last up to 2 weeks.
Keeping in mind that everything is behind the scenes (ex: automatic subscription confirmations, etc) -- would the best course of action be to add each opponent to another group in your roster while the game is in progress and then remove them after the game is complete? That way you get presence notifications when that player is online? Or is this a case where PubSub could be utilized?
I've also considered using multi-user chat so I'd always have access to every users online status without subscriptions, but that seems far from efficient when there could be up to 20k players online at any given moment. Definitely sounds like a battery hog on mobile devices as well.
My other solution is to used share roster lists. Create a roster list for each game and assign that list to each player. Then delete the shared roster list once the game is complete.
I would choose Pubsub here. Of course, this means that you have to do some server side work too.
Send a directed presence to the opponents. This will allow them to see your presence.
I would consider using a multi-user chat for each game, and your own extension to the MUC protocol to handle game-state messages (opponent has made a move). The user can have a roster of their friends at the "global" level, but can still communicate with their opponents (and receive presence) using the MUC level (unless they decide to then add them as a friend).
See also: Advantages of Pubsub versus MUC
I agree that using MUCS (instant) would be better in this scenario. If you need to cleanup pubsub nodes of unwanted subscribers, it will definitely be a pain in the ass.