I'm still really struggeling with this. Is anyone, like a maths wizz, able to help? This is a problem all decent network-game implementations need to face:
Here's my guess interpretation of the cubic spline interpolation solution to the dead reckoning problem. It doesn't work, I guess i'm using the wrong variables for t and apacket in the article, and perhaps some of my understanding is flawed - I can't work out how to implement the variables from the article in the Lerp4/spline function.
Code:
void Character::ReceivedMovementPacket(Vec pos, Vec vel)
{
old_pos = new_pos;
new_pos = pos;
old_vel = new_vel;
new_vel = vel;
}
Bool Character::update() {
// Handle messages received by packets here
Flt pos_on_spline = 1;
Vec coord3 = new_pos+new_vel*Time.d()+0.5*T.speed*(Time.d()*Time.d());
pos(Lerp4(old_pos,old_pos+old_vel,coord3,coord3-(new_pos + speed * Time.d()),pos_on_spline));
return __super::update();
}
- This code just sticks the character wherever you set vec pos. I want to just send the character extrapolated packet data and have it interpolate properly. Also, i'm not sure how to, "Make the object travel along the spline for T frames."
Explanation A: (Read part 'D' at the bottom)
http://www.gamedev.net/reference/article...cle914.asp
Explanation B: (Look at pages 19-20)
http://www8.cs.umu.se/education/examina/...uZhang.pdf
Related code (lots of comments):
http://www.mindcontrol.org/~hplus/interpolation.html
Related implementation:
http://www.mindcontrol.org/~hplus/epic/
Related reading:
http://www.gamedev.net/reference/article...le1370.asp
EDIT: Here's an implementation of what we've done so far:
http://www.cwkx.com/storage/V1.4%20Extra...ectory.zip
Specifically look at Character.h, Character.cpp (Lines 26-27), Game.cpp (Line 146 - pretending to receive character packets from server)