#### Archived

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

# homing missles

This topic is 6029 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

so i''ve got a missle object with x and z velocities and positions. then i''ve got a target at a give x,z position. I want to adjust the x and z velocities so that the missle will track at the enemy. Any suggestions?

##### Share on other sites
Run a counter to track the pos. of the target and just increment.

Targetx=Targetx+TargetxSpeed
Misslex=Misslex+MisslexSpeed
Targety=Targety+TargetySpeed
Missley=Missley+MissleySpeed

if(misslex==targetx)
{
if(missley==targety)
{
//boom
}
}

If you want to get more complex divided the board into an array and slightly modify the code.

Hope you understand, I never can explain things

##### Share on other sites
I think u want the missile to follow the object until it blows it up right?Well you can try this:You should see if the distance between the missile''s coordinates and the target''s coordinates is increasing or decreasing.If the distance is being increased then it is likely that ur missile will never hit the plane so you should increase the missile''s speed.You should do this for all the directions that ur objects are moving...
Hope this helped

##### Share on other sites
this is off the top of my head,

  void missle::act(){calcDesiredChangeTheta(target, &angle, &polarity);missleHeading += polarity * ( maxTurnAngle < angle)? maxTurnAngle: angle;turn(angle);   // calculate vx, vymove(forward); //add vx+cx, vy+cyif(collision()) explode();}

the missle has a current heading and a max turn angle.
calcDesiredChangeTheta gets the angle difference between the target and the missle, and returns that angle, and its polarity(+/- 1).

once you get the new heading, modify vx and vy, and then modify x and y

##### Share on other sites
Another idea is to have the missile track the object only when the missile is within'' a certain distance of the object. Kindof like how heat seaking missiles work. They only work if they get close enough to the heat source to detect it.

1. 1
2. 2
3. 3
4. 4
Rutin
14
5. 5

• 10
• 11
• 9
• 14
• 10
• ### Forum Statistics

• Total Topics
632652
• Total Posts
3007661
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!