• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
_Flecko

Homing rockets

12 posts in this topic

I didn't think it would be too hard, but I'm having some difficulty getting homing rockets to work in my 2D game. I tried having them rotate towards whatever their selected target was and then accelerate in the direction they were rotated in, but what tends to happen is that they'll just circle their targets - it's like centripetal force, since they always rotate to face their targets unless they come at them straight on, their acceleration will be tangent to their velocity. Does anyone have a good algorithm for rocket homing they wouldn't mind sharing?
0

Share this post


Link to post
Share on other sites
Quote:

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.
0

Share this post


Link to post
Share on other sites
Over-rotate by about 15 degrees--I believe this is how homing missiles in real life work.
0

Share this post


Link to post
Share on other sites
Ok, what I ended up getting to work is sort of a combination of your two ideas. Each frame the rocket takes two vectors, the negative of its current unit velocity and the unit vector in the direction of its target. It multiplies each by some factor and combines them to get another unit vector, which it multiplies by its acceleration rate and uses to change the velocity. So, it's not really based on rotation, but it does work by selecting a vector that aims to the side of its target.
0

Share this post


Link to post
Share on other sites
This is not a problem with the missile not anticipating the target's movement - rather, it's a problem that the target is inside the missile's turning circle, so it just orbits.

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



Mark
0

Share this post


Link to post
Share on other sites


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.
0

Share this post


Link to post
Share on other sites
Your problem is that the missile is always trying to fly at top speed. If it slowed down, it could turn in a tighter circle and hit the target.

Personally, I would code it like:


struct missile
{
vec3 pos;
vec3 velocity;
vec3 accel;
float spring_const; // = 0.3f or so.
float min_speed;
float max_speed;
// etc.
};

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;

// done!
}



where "damp_spring" is the function I define here.
0

Share this post


Link to post
Share on other sites
Quote:
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.




target------>BOOM
/
/
/
/
/
missile
0

Share this post


Link to post
Share on other sites
If you want a "newtonian" missile that only uses forward thrust, simply trying to point at the target isn't enough. What you need to do is determine the direction/velocity that you need in order to hit, then subtract the current velocity from that to get the direction you need to apply force in. Point the missile in this direction and apply thrust. This means the missile might point 90 degrees to the side when performing a turn, for example. In an orbiting situation it may even turn backwards to break the orbit.
0

Share this post


Link to post
Share on other sites
Sidewinder missiles will over-correct by 15 degrees, the heat sensors (I think it's an array of like 128 by 128, lower on earlier versions) pick up the heat as the missile rotates, and kind of zig-zag up to the target. You might try to have a 30 degree arc divided into two, then have the missile either slightly up, or down at certain intervals until that zone loses contact. Like the upper zone causes the missile to steer upward, then loses contact, so the missile then thrusts down until the lower zone loses contact (and explodes if both zones lose contact, meaning the missile has overshot the target, or is beside the target)

Check out http://www.howstuffworks.com it's got all kinds stuff about sidewinder missiles and what-not
0

Share this post


Link to post
Share on other sites
Quote:
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.

Linky

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 :)
0

Share this post


Link to post
Share on other sites
i got this in this same forum while ago.. i never tested it but it should work i think, tell me if it does.

// gamedev - homing missles:

//starting position
//bullet speed
//target position
//target velocity
//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;
}
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0