Posted on October 12, 2005 by Doolwind

Mighty Fine Spline

I’m experimenting with an idea for the movement of the missiles in CIC. Rather than having the missiles move independently using their speed and direction I’m pre-calculating the missile paths. The missiles still use the movement under constant acceleration equations (suvat) to have correct movement speeds, however my new approach comes with a lot of advantages over simply calculating the new position based on the old one each frame. These advantages are:

1) The entire path for a missile can be pre-calculated before it launches meaning a very small calculation each frame to find it’s current position.
2) Very little data needs to be sent over the network. The spline calculation is done based on the control points chosen by the user, and the acceleration of the missile. The server can use this minimal information to create intricate missile path’s.
3) The positions can’t get ‘out of sync’ between clients and the server. Rather than using an offset based on the current position, the position each frame is calculated independently. This means that even running the game at completely different frame rates with large pings (>1 second) the two games will always display the same world to each user.

So far I have a simple implementation of the splines. My next step is to create counter-missiles with shoot down the current missiles I have in the game. Due to the use of splines I have another new technique I’m going to experiment with. As my missiles paths are pre-calculated, I will be able to pre-calculate the counter-missile paths as well. To look realistic the counter-missile needs to fly towards an intercept course with its target.

Usually this is complicated, as each time the target missile changes course; the counter missile must also correct its course to make sure it intercepts the target missile. However, as I’m using splines and I already know the complete path of the target missile, the counter missile’s path can be created to seem as though it’s reacting to the changes in the target missiles path. Every control point on the target missiles path will have a corresponding control point for the counter-missile.

If all goes according to plan this means that only a handful of control points need to be sent over the network for each missile and counter-missile meaning an extremely large number of missile’s can be fired and the game should handle it nicely (good scalability).

If this seems a little confusing, or if you’d like to know more, let me know and I can mock up some simple diagrams to show you exactly what I’m talking about.