Archived

This topic is now archived and is closed to further replies.

NewDeal

Heat seeking missile

Recommended Posts

NewDeal    134
Im currently working on a 2D space shooter (topview). Ive been trying to figure out the best way to control heat seeking missiles. The missiles can only move forward with a freedom of 45 degrees to each side (in steps of 5 degrees cuz of the sprites). Now im simply checking if the targets x-position is less/greater than the missiles x-pos. If this is the case i add/substract 5 degrees from the missiles heading. This basicly works but im not getting the movement effect i want (they dont move naturally). Does anybody know of a better way to do this ? Or where i can find info on this topic. Thanx

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
The way I see doing heat seeking is by converting the angle of the heading to a slope, then just check to see on which side of the line is the target. If its to the right then turn clockwise else counter clockwise. Then you''ll just need to do some code for when the target is on the line infront of the miscile so that it doesn''t gitter back and left and right, and for inbehind so that it will turn instead of going straight. To check if the target is in front or in back siply invert the slope and do another check.
If anyone has better ideas let me know.

- 60815

Share this post


Link to post
Share on other sites
Spellbound    122
I would give the missiles these properties:

struct Missile
{
Target;
Position;
Speed;
};

Every time the missile should be moved the speed is added to the position, and then the speed is accelerated towards the target. If the missile misses the target it will take some time before it is able to reverse its speed, which is quite realistic without imposing to much physics into it.

When the missile is rendered it is always rendered so that it faces the target.

Share this post


Link to post
Share on other sites