Hey, I got extrapolation working (well better than it is in the current version) if you're interested. I do what you recommend as far as getting the next position goes, but to make it a bit smoother, I interpolate to the position over a few frames, so there is a TINY delay. So push now looks like this (I've added a class variable as well -- Vec nextLoc) :
Code:
void Character::push(Netpoint &n) {
if (Dist(n.pos,pos()) > 10.0f) pos(n.pos);
Vec extrapolated = n.pos+(n.vel*((Flt)(n.packetTime - lastTime)/1000.0f));
pos(Lerp(pos(),extrapolated,0.25)); // start the "move" process so he doesn't just warp
nextLoc = extrapolated;
angle = n.angle; //update the angle, we can make this smoother in the future
}
Then in the update() function I added something like this to the top:
Code:
Bool Character::update() {
// move to the extrapolated position
if(Dist(nextLoc, pos()) > 0.01) // it is close enough
pos(Lerp(pos(),nextLoc,0.25));
... rest of code down here
}
At this point the character just warps around.
So I overrode the animate() code to make him do a running animation if necessary:
Code:
void Character::animate()
{
__super::animate();
if(Dist(nextLoc, pos()) > 0.01)
cskel.animate(L"../EsenthelEngineSDK/data/anim/run.anim", Time.time(), 0.5);
}
Obviously this won't take any other animations into account, but that could be implemented easily enough.
I also changed the tick rate of the update in my code to 100 instead of 10.
This creates a smoother result at the expense of higher bandwidth usage.