Archived

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

homing missles

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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, vy

move(forward); //add vx+cx, vy+cy

if(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 this post


Link to post
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.

Share this post


Link to post
Share on other sites