Creating a homing/tracking missile

This is will I will provide a copy of my blog on Pulsar development. You can find the original blogs at:

http://quadgnim.spaces.live.com

Creating a homing/tracking missile

Postby lgrant » Sat May 02, 2009 7:26 pm

Read original post here

Missile Tracking

A dumb fire and forget missile is easy as it might just fly along a straight trajectory until a timer expires and you remove it. If you want a homing or tracking missile you can do this pretty easily too. To brute force it you might simply check your target every frame and turn the missile to face the target. However, this would result in an unnatural movement of the missile. What I realized from the MS networking sample, which interpolates network object between two points, was that the same exact technique can be used on a homing missile. To do this you interpolate between the missiles position and forward vector, the targets position, and the vector from the missile to the target. You can use the LERP method rotate the missile between it’s current forward vector and the vector calculated by subtracting the target position from the missile position.

This isn’t exactly like interpolating network objects because the network objects you interpolate both the rotation and position. For a homing missile like effect you just interpolate the rotation, but let the missile continue to travel along its forward vector at whatever speed it travels. Furthermore, don’t readjust the missile every frame, but readjust it once or twice a second.

I also want to allow the missile to loose its homing lock on the target, allowing the target to out maneuver the missile. An easy way to do this is to calculate the dot product between the missile’s forward vector and the vector between the missile and target. If the dot product is <0.995 it looses the lock. Once it looses the lock set the target to null, and from that point on allow the missile to just continue on its forward vector without any interpolation until its timer expires. You might want to tweak 0.995 to your personal desire.
QUADgnim

Image
lgrant
Site Admin
 
Posts: 13
Joined: Thu Feb 12, 2009 4:57 am
Location: Pennsylvania, USA

Return to Blogging

Who is online

Users browsing this forum: No registered users and 1 guest

cron