Fixing the timer and end game
The last thing we need to adjust for multiplayer is the timer that times our run and the end of the game, stopping the entity spawners and showing the game-over menu. So, let’s get started on this last effort.
Synchronizing the timer
To synchronize the score timer, we simply have to do the following three things:
- Add
MultiplayerSynchronizer
to themain.tscn
scene.
Figure 11.26 – The Main scene tree after adding MultiplayerSynchronizer
- Synchronize the
_time
property of theMain
node.
Figure 11.27 – The Replication panel tracking the _time property of the Main node
- Now, disable the
_process()
function from within_ready()
if we are not running on the server:func _ready(): # Other code if not multiplayer.is_server(): set_process(false)
That is all we need to do synchronize...