netfox icon indicating copy to clipboard operation
netfox copied to clipboard

Interpolation glitches weirdly for 2d movement.

Open gk98s opened this issue 1 year ago • 1 comments

My game currently runs 2 seperate projects 1 for the client and 1 for the server. I got RollbackSynchroniser to work but I can't get TickInterpolator to work properly. I'm running on 20 TPS and even without the interpolator the movement looks smoother compared to using the interpolator which is supposed to make it smoother. I'm assuming I'm doing something wrong but I really can't figure out what it is I have been looking at the example projects and the docs for hours and can't find a fix. Here's a video demonstrating it.

https://github.com/user-attachments/assets/edd4438f-b1d3-4aff-97dd-93adcc82409e

I have tried using :position as the property, I got the same result. I tried setting the network ownership of the interpolator to the player, that also didn't change anything. What could possibly be causing this problem?

gk98s avatar Sep 23 '24 18:09 gk98s

Here's the code for my movement. Also, you can have access to my repository if you need further debugging done.

gk98s avatar Sep 26 '24 15:09 gk98s

Managed to fix on user project with the following change to TickInterpolator:

func _after_tick_loop():
	if enable_recording:
		push_state()
		PropertySnapshot.apply(_state_from, _property_cache)

The change is adding the PropertySnapshot.apply call. Apparently what happened was the following:

  1. Frame 1
    1. TickInterpolator interpolates from state A to B at 100%, resulting in state B
  2. Frame 2
    1. Rollback tick loop is ran
    2. RollbackSynchronizer applies the result of the simulation, state C
    3. TickInterpolator saves B as starting state and C as target state
  3. Frame 3
    1. TickInterpolator interpolates from state B to C at 0%, resulting in state B

The glitch happened due to RollbackSynchronizer applying state C on frame 2, and then right after that, TickInterpolator applying state B on frame 3. The fix is applying state B in Frame 2 as part of the TickInterpolator code.

Interesting that this hasn't surfaced in Forest Brawl. I'll confirm the same in the example projects and push a fix.

elementbound avatar Oct 10 '24 11:10 elementbound