# cubic spline interpolation

This topic is 3863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

confusion!! alright i hardly understand the maths, but i could get round it. i was just gonna folllow the equations and hope it worked... as for implementing.,... well that would be problematic... but again if i put my head to it i could do it .... one thing i have a problem is... to plot the curve... u need all 4 points... so u have to wait until point 4 is received in the packet.. but point 4 is the players most recent position... so surely u wudnt just put the player there... theres no need for point 3.. u can take point 1 and predict point to based on speed. fair enough... its not much better than just updating the player whenever the packet arrives

##### Share on other sites
Well, you wouldn't typically want to just go to the current position, as it will appear choppy. Interpolation of sorts is typically much nicer, whether it be spline, cubic spline, linear, whatever. So, if you want to do inerpolation using 4 points, basically what you do is save the LAST 3 points, when the 4th point comes, you should already be at point 3 (or close), so you would just interpolate from that point on, then when point 5 comes, you would drop the 1st, move them all back one, and start interpolating from your current position, this way the last few points affects how they are moving, but aren't used for anything but the calculation (aka, you aren't actually IN those areas by the time point 4 arrives). I beleive a common thing is to get the players last movement vector, and do that based on the players speed until a new packet arrives, calculate the difference and then merge towards the new location/direction, if the difference is to great (aka, bad lag) move them to that position (player appears to 'jump around' on the screen. If you store the last 4 control points, your player should never fall to far behind, even with bad latency because the points will be stretched out a bit. The amount of delay between what you're seeing, and what the guy playing the game is seeing is dependant on how fast the packets are updated of course, however it will look mostly smooth, even if not 100% accurate.

##### Share on other sites
Quote:
 i hardly understand the maths, but i could get round it

No. No, you can't. What you need to do is to learn the math.

##### Share on other sites
well i understand the principal of it. i have worked through the equations and followed the variables to see what actually gets done to each number. i have done interpolation before.

thanks Ready4dis... i understand what you are saying. i had this thoery that it would be sliightly behind, since you dont put the player on coord 4 instantly cus it would look jittery. i thought for coord 3 you need coord 4 because you are predicting it from coord 4.... but if you drop coord 1 and move them all up

so each time you get a new coord, whether it may be predicted or a packet... you move all the others up. so 4 becomes 3, 3 becomes 2 and so on. so 3 will be at 1st the predicted one, but when u get number 5... or the new number 1.. 4 will become 3.

i dont if u can understand what i just put, its more or less what you just said.

thx anyway!

##### Share on other sites
Interpolation == runs behind at a (mostly) verified position
Extrapolation == runs at "current time" at best-guess position
Look at EPIC in the Forum FAQ for some code that can do both.
Note that cubic splines can't really do extrapolation because there's no "forward" points to extrapolate from.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 17
• 14
• 10
• 9
• 11
• ### Forum Statistics

• Total Topics
634095
• Total Posts
3015501
×