Does this library have rewinding back in time on server to check if player did hit server side enemy (pve)? #193
-
I added library to my project and player movement works very good, i checked all docs and didn't find or missed part where it says if i can go back in time on server and check if player did hit pve enemy or another player so latency is taken into account Maybe i got this library wrong and there is lag compensation for player movement, effects, firing, etc, but without rewinding back in time? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 12 replies
-
Hi, glad to hear it's working well! Yes, there is absolutely rewind, that's what the Rewinding to check for hits should be doable, although a bit tedious with the current API. You can rewind state to a given tick by emitting After that, you might need to update the physics state directly through PhysicsServer, by calling body_set_state, because Godot only updates physics state before the physics process callback. After that, you can do your raycast or collision check to see if the hit landed. Note that this also needs some fiddling with the physics updates, you either have to manually do the cast ( see example ), or force update on your RayCast or ShapeCast node ( e.g. force_raycast_update ). This comes from how Godot handles physics updates ( which is reasonable for most use cases ), but I am planning to make this a bit easier in future versions - I'm considering adding a NetworkRollback.rewind method to get back to a specific state, and possibly a config flag to RollbackSynchronizer that will make it do the physics updates automatically on rollback. |
Beta Was this translation helpful? Give feedback.
Originally I figured that Godot's MultiplayerSynchronizer should be fine for this kind of thing, since the server is the authority, and the node will just broadcast the state. The difficulty with that is that the MultiplayerSynchronizer is not tied to netfox's tick loop, and does not do interpolation either. I'm still considering what would be the best way to handle this, but for now I have a class that I'll add to netfox in the coming weeks.
I'm already using it in my own game to test it, so I can share here:
EDIT: The node below is available from netfox v1.3.0 and higher, you can grab that instead of copy-pasting the code.
StateSynchronizer