homing missles

Started by
3 comments, last by zoomcrypt 22 years, 1 month ago
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?
SkullOne - Hero Interactivehttp://www.hero-interactive.com
Advertisement
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
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
-Da Mr.RaSt3RiZah-
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
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.
Rhino2876

This topic is closed to new replies.

Advertisement