🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Heat seeking missile

Started by
2 comments, last by NewDeal 24 years, 4 months ago
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
Advertisement
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
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.
I got it working now

Thanx

This topic is closed to new replies.

Advertisement