I'm trying to make lag compensation system for my authoritative server project. Every object that moves over the network keeps a log of where it previously was in past game logic updates, up to the past second. Additionally, I made a function that can interpolate between game logic updates (since clients will see the objects interpolated between the otherwise slow game logic updates)
I thought I could write a "rewind" function that just tells all the networked entities to go back to where they were at a certain timestamp, then perform the necessary physics calculation, update the game accordingly, then return the objects to where they're supposed to be. However, because of how physics works, it seems like it's not very straightforward to just write a single function that does this. I tried something like:
func past_check():
var box_orig_pos = box.translation
box.translation.x = 0
raycast.force_raycast_update()
print(raycast.is_colliding())
box.translation = box_orig_pos
This was just meant as a simple test to see if it was possible to do what I'm describing in a single frame, but the print statement always prints false, so it doesn't seem quite so simple.
Any ideas for how to do this? Am I going to have to find a way to stagger the function over more than one update so that the collision checks will work properly? I'd also prefer to avoid having to alter the position of the body directly, since it's likely that many rewind checks will need to happen frequently. Can I use a world or something like that?