Kehom / GodotAddonPack

A collection of pure GDScript addons for Godot
http://kehomsforge.com
MIT License
190 stars 15 forks source link

[Network] Server rewind #17

Open fairhat opened 4 years ago

fairhat commented 4 years ago

This is more of a question and possibly feature request:

In FPS type games it's common that the Server goes back in time (for a maximum of N ticks) to check if someone's bullet hit another player (if a client says he hit someone but the server did not see it on his tick, due to network delay).

Most FPS games favor the shooter (which means you can run around the corner and get hit like a second afterwards because the player shooting you had a latency of ~500ms), while others favor the one running away.

Is it currently possible to implement something like this with this library? I know that Godot does not allow rewinding a scene and doing so would cause a lot of other problems (all clients would rewind their states too during that tick)

However it'd be already "good enough" to get history data for that action:

If i was able to know this i could reconstruct an invisible bullet + hitbox of the player and use smth like raycasting to check it.

Edit: Assuming i have Aim and position of all players stored in previous state snapshots(!)

Kehom commented 4 years ago

Well, this is rather difficult to be (properly) done purely from GDScript. I'm not sure if GNative would be any better. My original intention was to perform the entire correction and re-simulation automatically, but that required to indeed "warp back in time", which is not exactly easily done, much less in a generic way. What I can do, however, is provide means to retrieve a specific snapshot, get data from it then the server code could act on that information.