Repository navigation
feat: Add SynchronizedTimer - #663
Open
CardboardCarl wants to merge 1 commit into
Open
CardboardCarl wants to merge 1 commit into
CardboardCarl wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds SynchronizedTimer, an extension of Godot's default Timer node that takes advantage of netfox's rollback system to synchronize the timers across multiple clients/servers.
How to use
You can use SynchronizedTimer just like a regular Timer node! Keep in mind, though, that
start()will only start the timer locally. Once the authority callsstart_remote.rpc(), all clients should automatically start the timer and keep in sync.You can also adjust the sync interval, as well as a threshold for the maximum time drift allowed between the client and authority before forcing a synchronization.
Caveats
It is not recommended that
autostartbe enabled for SynchronizedTimer nodes, as it may not allow the nodes to sync properly due to one node being added to the scene before the other.At this time, SynchronizedTimer has only been tested thoroughly with
one_shotenabled, but I hope to test it further in the future. In my opinion, it's not a huge deal to be without this option for the moment, as the most likely use case will be with one-shot timers anyways (round/game start, countdowns, etc.).Future Additions
Compatibility with
one_shotdisabledalternate signals for reporting a server-confirmed
timeoutvs a localtimeoutsignal(possibly) investigate ways to send less data with RPCs, such as by using NetworkEvents or something similar
Code 100% human-made, with some comments generated and human-edited. Happy to change anything if there's an issue.