Members - Reputation: 196
Posted 15 July 2005 - 08:46 AM
Posted 15 July 2005 - 09:21 AM
acceleration will be tangent to their velocity
I think you answered your own question there :)
Instead of accelerating towards your target, save out your velocity and modify it directly by some homing factor.
Members - Reputation: 196
Posted 15 July 2005 - 06:23 PM
Crossbones+ - Reputation: 1692
Posted 16 July 2005 - 12:09 AM
The missile should be able to determine whether the target is inside its turning circle. If so, it should fly in a straight line (or possibly even turn in the opposite direction) until the target is outside its turning circle. Then it can resume normal homing behaviour, which will result in it flying straight, turning around and coming back bang onto the target.
For added security, make the circle you test for slightly bigger than the missile's actual turning circle.
Here's a picture
Posted 16 July 2005 - 12:26 AM
Rotate to aim at a target point which is a projection of the targets current movement vector (project X time periods ahead with X getting smaller by current distance between missile and target divided by some velocity).
It wont solve all the endcases but can make your intercept course more efficient.
Also limiting the maximum velocity of the missile can make your turn radius (during terminate maneuvering) smaller. It should still be fast enough to close with the target, but also be somewhat limited when close to the target.
Members - Reputation: 767
Posted 16 July 2005 - 07:12 AM
Personally, I would code it like:
float spring_const; // = 0.3f or so.
void missile::home_on_target(const vec3& target, float timestep)
// ideally, our velocity will be directly at the target, at top speed.
vec3 to_target = (target - pos).set_length(max_speed / timestep);
// adjust velocity.
damp_spring<vec3>(velocity, to_target, accel, spring_const, timestep);
// don't set min_speed too high...
clamp(velocity, min_speed, max_speed);
pos += velocity * timestep;
where "damp_spring" is the function I define here.
Members - Reputation: 140
Posted 16 July 2005 - 07:34 AM
Original post by bytecoder
Over-rotate by about 15 degrees--I believe this is how homing missiles in real life work.
No, in real life radar-guided or heat-seaking missile usually fly towards the place where the missile expects to find the target when the missile reaches it.
Members - Reputation: 410
Posted 17 July 2005 - 06:54 PM
Members - Reputation: 187
Posted 17 July 2005 - 07:30 PM
Check out http://www.howstuffworks.com it's got all kinds stuff about sidewinder missiles and what-not
Members - Reputation: 588
Posted 17 July 2005 - 07:58 PM
Seek attempts to steer a vehicle so that it moves toward the goal. This is in contrast to a central force (such as gravity) which causes an inward acceleration and so leads to orbital motion.
Tip: Look into "Seek And Flee", "Pursue and Evade", "Obstacle avoidance" and finally "Combining behaviours" in his gdc paper from 99. Better yet, read the text in the paper and watch the animations on the homepage(the text in the paper is easier to understand).
This will give you a great missile that homes to where the character is going to be and avoids obstacles :)
Members - Reputation: 106
Posted 17 July 2005 - 10:56 PM
// gamedev - homing missles:
//Vector2D LeadTarget( Vector2D sp, float bs, Vector2D tp, Vector2D tv )
Vector2D D = tp - sp;
float E = D.Dot( D );
float F = 2 * tv.Dot( D );
float G = bs * bs - tv.Dot( tv );
float t = ( F + sqrt( F * F + 4 * G * E) ) / ( G * 2 );
return D / t + tv;