I'm working on adding server authoritative lag compensation to my FPS game - specifically by using raycasts for hitscan bullets. My algorithm is as follows:
- Clients send inputs to the server
- Process movement and save all player locations
- For each "shooting" input received,
3a. interpolate player positions to the time the shot was taken (based on previously saved locations)
3b. Run a raycast while players are in those positions
4c. process hits - revert players to saved locations from step 2
- send all important info to clients
After struggling with this on and off for like - years (lul) - I found someone that could tell me that in Godot "Physics bodies will only be in their position on the next frame". This didn't make sense to me at first - but now does completely. If this is the case - I can't do raycast based lag compensation at all because all the times I interpolate player positions in step 3a they aren't actually moving at all. And based on how this works - I can't let the server process n frames to update player positions for every n shots it needs to process as that would freeze the game for n ticks.
Anyone have any insight on how I could do raycast based server authoritative lag compensation in Godot?