#How to create a Seamless game loop

1 messages · Page 1 of 1 (latest)

mystic kelp
#

Hello, In the game I'm making in my game loop I need some things to happen at certain time during the match every time

Like move counters to x position on 10 second mark, on 20 second mark change lighting, etc etc

And I need it to be tick accurate/happen for everyone at the same time

What's the best approach for it? Right now I can think of 2 approaches

  1. make 1 big animation/timeline for my game loop that will fire events/ change the value of objects I need depending on the game clock and play things locally

  2. Make a list of all the events and the time they need to be fired at and send them over the RPC (personally I don't think this is correct approach or this one get messy but I might be wrong)

Is there a better approach? Need help

#

Game is in photon fusion Shared mode btw

indigo meadow
#

DateTime.UtcNow should be accurate to a few milliseconds

#

so you replicate the start time to all clients, and when (startTime + 10 < DateTime.UtcNow) or something, do whatever needs to happen at the 10 second mark

mystic kelp
daring trench
#

I'm not exactly sure what you mean by seamless, but you need to actually explain what your game loop is before we can properly help you.

Seems like you could use a Timeline that is started with an RPC to all clients. Or you could use whatever Photon has for Server Time that should be synced to clients

mystic kelp
# daring trench I'm not exactly sure what you mean by seamless, but you need to actually explain...

Sorry by game loop I mean events that will be fired periodically in every game at certain time stamp and run for set amount of time

For example :
In stage 1 :

at 10 second mark counters will move from position A to position B in 10 seconds
At 20 seconds mark enemies will spawn until 60 seconds mark
At 30 seconds mark enemies will start charging towards players
At 60 seconds mark boss will spawn and start attacking
At 75 seconds mark lights will start flickering for 5 seconds
At 80 seconds mark lights will go out completely
At 90 seconds mark player's flashlights will be enabled

Same way other sets of event in stage 2 and so on

And by seamless i mean firing of these events/effects of these events be executed at the same time across all clients

For example : counters should start moving for ALL clients at 10 seconds mark, should be halfway there at 15 seconds mark

daring trench
#

Ok, by seemless you mean syncronized. If its all timers then all you need to do is sync the start the time. You can have a local game manager start your timer. As long as the timer starts at the same time everything else will follow

mystic kelp
daring trench
daring trench