- Home /
Network | Math: Smoothly lerp between inconsistent intervals
So i'm working on a 1v1 2D game (using rigidbody physics + forces to jump/move), i send position+velocity data once every 0.05 seconds IF the distance between the last sent position and the current position is larger than a set amount.
So data arrives at inconsistent intervals and lerping causes a jittering motion. Is there anyone with a large enough brain to help me figure out how to smoothly lerp the position of the opponent that's received at inconsistent intervals? (e.g. intervals of: 0.06, 0.13, 0.83, 1.64, 0.67 etc)
Currently the smoothest method i've tried is to just feed in the opponent velocity, however the actual positions become out-of-sync over time. Ideally it should seem like you're playing locally, as in no jittering/hiccups (even though position is slightly behind actual position due to network delay).
I'm using C# but an explanation of the logic for the solution would be good enough!