Hi guys, so Im feeling a little upset because a game Ive been working on might be flawed due to multiplayer, but I just wanted to know if there was a fix.
So essentially the game works and is controlled by a timer. The timer counts up in generations, and also displays a little GUI bar which shows far long until the generation ends. Long story short, at the end of each generation, if the player isnt in a safe spot, they die.
However, of course with multiplayer, these timers are completely out of synch. Since the timers are client based, if I start a game, and then someone joins 2 minutes later which is midway through a generation, we are both gonna have different results, which means I will die later, and so on.
Can you think of any possible fix for this?
After joining, they’re just an observer till then end of the current cycle. Then they get to start playing?
But how would I make that happen?
Tough one, but I have to solve this for my current project too. My approach will be like this:
One client is authoritative (or the server if you are full client/server). The server then periodically (every second likely in my case) sends out a time float variable. Each receiving client updates their time appropriately offsetting that time based on the current measured ping (basically add half the ping value). This won’t be rocket science accurate but it will be accurate enough. Note that each client will continue to increment their time variable even without receiving an update from the server. So when a time update packet arrives they have predicted time and the time they get from the server.
Its pretty tough, but I think I’ve found some ways using RPC