we now capture the clients state along side the input
using this we can now compare the incoming state with the captured state at the time of the tick
if a deviation is found we run the simulation starting from the incoming state using all inputs that haven't been processed
during simulation we also need to stop taking in new inputs on the client.
using move and slide
move and slide assumes physics delta
so we have to do some clever math to cancel it out while applying process delta and then the inverse after the call.
The need for 1. is due to the fact that running the simulation using move and slide actually moves the player. so to prevent constant simulations we need to only do so when a deviation is found first. otherwise we would need a "ghost" characterbody3d that we would constantly be moving and checking against. and can become quite complicated when things like state machines are introduced.
Replace TestMotion with MoveAndSlide Fixed various errors.
Fixes https://github.com/grazianobolla/godot4-multiplayer-template/issues/8
The propose solution is 2 parts
The need for 1. is due to the fact that running the simulation using move and slide actually moves the player. so to prevent constant simulations we need to only do so when a deviation is found first. otherwise we would need a "ghost" characterbody3d that we would constantly be moving and checking against. and can become quite complicated when things like state machines are introduced.