Dead Reckoning for racing games - What are some good ideas?

Hi all,

I’m finally at the stage where I get to implement dead reckoning in my game…

I have tried a few things already, like projecting a vector in front of the car’s trajectory and then mirroring it along the car’s local x and y. Previously, I have tried graphing a catmull spline curve, but I have no idea how I should position the curve, or what to do with it, etc…

I suppose there are not a lot of people who have experience in this, but if you have any good ideas, that would sure help.

My goal is to smooth out a very fast moving vehicle, also projecting it slightly into the future.

Are we talking networking or just in general?

Networking.

Forgive me for being thick, but isn’t it just as simple as doing forward euler integration? As in, something like this:

You receive a position (P) + velocity (V) for T0
The position at T1 is (P+V*(T0-T1))
And then correct the position as need be when you get updates

I’m sure there are more fancy things you can do.

Right… but then I probably need to smooth it out. The car is after all traveling around 100+ MPH on average. Any slight lag is going to throw the car off by a few feet.

Yes true, the smoothing out part can be done like this (and how you do most smoothing out when doing lag compensation).

P = position
E = estimated position
V = velocity

  • Receive P0 and V0 for T0
  • Calculate E1 from (P0+V0*(T0-T1))
  • Store E1 somewhere (array, local variable, etc.)
  • Smooth from P0 to E1 over (T0-T1)
  • When you receive P1 and V1 for T1 you smooth from E1 to P1 to correct your prediction
  • Calculate E2 from (smooth(E1, P1) + V1 * (T1-T2))
  • Start over from step 2

And the smooth algorithm can be whatever you want, linear, cubic, spherical, etc. whatever looks best for your game.

Edit: if this is stuff you already know, say so, so I can stop responding ;p

The smoothing algorithm isn’t just Vector3.Lerp right? How would you make a cubic smoothing algorithm?

Well, that’s just a normal cubic interpolation, for example a bi-cubic interpolation like this: Cubic interpolation - Paulinternet.nl
Honestly though, for this stuff linear interpolation works pretty well in my experience.

Thanks fholm! I’m going to try something like you were saying, as it seems to make a lot more sense than what I was trying before… And I’ll check out those linear and cubic formulas and see how they work.

Glad I could be of help, I corrected my post with the steps outlined in it as I had said V0 where it was supposed to say V1.

I think I got it now… See, I never understood how to use a spline graph for smoothing algorithms. The link you gave me helped a lot. I now have a nice catmull-rom interpolate script working. Next, I’ll be fine tuning the leading vector to make better predictions.

Would you mind sharing(if you can) that script, the scritp that I am working on is too basic and results in movement chopping.