Hey all,(adsbygoogle = window.adsbygoogle || []).push({});

This is a bit of a broad subject so I'm not sure which section it best applies to, but here it is anyway.

I'm working on a massively over-engineered version of the original Asteroids game. How over-engineered? Well the problem I have right now is desigining and implementing a guidance system that will be used for missiles targeting asteroids, and aliens targeting the player. It will later be extended to navigating around obstructions via a series of waypoints.

I have an algorithm that finds the point of intersection of asteroid and missile, but I don't have an accurate enough method for calculating the duration of flight (to get the point accurately).

Asteroids have a velocity vector with aconstantmagnitude and angle.

Missiles have:

- A velocity vector with a
variablemagnitude and angle.- An intial rotation based on the rotation of the ship. Variable name: rotate
- A fixed rate of acceleration.
- A maximum speed of rotation.

When fired, the goal of the missile is to align its velocity angle with the angle between the missile and the target point. I have a function calledthetawhich returns the difference between these two angles.

When theta is:The range of angles is from -179 to 180 degrees.

- Positive: The target is off to the right of the missile.
- Negative: The target is off to the left of the missile.
- Zero: The target is dead ahead of the missile.

In the game, an angle of 0 degrees (missile rotate) is facing right.

The problem I'm having at the moment is that my current commands tell the missile to rotate right or left based on theta, and as a result the missile tends to fishtail around the line of intersection and often ends up overshooting the target point.

What I need is an algorithm/equation to stabilise the missile's angle by "dampening" the velocity vector to theta=0 in as short a time as the thrust and rotation of the missile will allow. Once the missile has the right angle it will pass right through the target point.

The missile can only apply an acceleration in the direction of rotation.

Once I have an accurate hit on a point I can calculate the number of steps to reach that target, either by simulating the path before actually launching it, or with an equation, apply a function to determine the length of the path (possibly less expensive processwise).

Any ideas?

Thanks :-)

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# 2D Missile Guidance System

**Physics Forums | Science Articles, Homework Help, Discussion**