I’m making an idle game with semi-multiplayer.
My game uses Unity as a client and as a server Unity Gaming Services (UGS) C# Cloud Code Modules with UGS Cloud Save.
Players click “start” which then starts idle/automated combat on the client. Players get experience and items from combat.
I want this to happen real-time on the client, it takes too long to pre-generate all the combat and loot on the server.
But I want my server to check everything so there’s no cheating.
I want to prevent cheating because trading items between players will be a big part of the game.
My plan at the moment is the following:
- player starts the game and sends a request to the server for a Random Number Seed (RNS)
- server generates the RNS and stores it in Cloud Save then sends it back to the player
- player clicks “start” and combat is processed real-time using the RNS, items are also generated using this
- on significant events, for example level up, every 10 seconds or on an item drop, the client pings the server to let it know something important happened
- the server then re-calculates all the combat up to that point and if everything checks out it saves all the rewards to Cloud Save
- the server then generates a new RNS that will be used after the next event (to
prevent players calculating rewards a long time up front) - on the next event the client pings the server again and then starts using the new RNS
- repeat from 5
My main concern with this is that I have duplicate combat code, not exactly, but I need to ensure the combat logic is exactly the same on client & server.
Is there any way to manage this sort of thing? I have no clue.
The code won’t be identical either, because the client is showing lots of visuals that the server won’t have to for example.