Heat seeking missile
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
March 05, 2000 09:13 PM
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
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement