📜 ⬆️ ⬇️

Aircraft Homing Techniques in Game Development

image

A year ago, I graduated from the Moscow Aviation Institute and got the qualification “Engineer”. But since by that time I had been working as a programmer for a year and knew that I would work in this area in the future, getting a “crust” did not become a turning point for me, unlike my many classmates. The knowledge gained in 4-5 courses seemed to me quite interesting and broadening my horizons, but not too useful for working as a programmer. However, there are several topics that helped me in my work. I want to tell about one of them, and her name is the methods of pointing the aircraft.

Under the aircraft in our courses always meant a controlled aircraft rocket, most often of the air-to-air type. Targeting a missile at a target is controlling its flight so that it finds itself in the meeting area with a target. The goal, of course, does not want this meeting and can make various maneuvers.

So how can targeting techniques help in game development? The first and most important thing that can come to mind is to control one object in the game so that it collides with another object. For example, self-guided projectiles fired by enemies into a player, or a bot that collects objects moving in space ... Well, or as controlling a hockey player in the Russian AI Cup 2014 , so that he quickly captures the puck or runs to beat an opponent).
')
Since the coordinates of ours do not change continuously, but discretely, then the area of ​​the object’s meeting with the target will be the circle with the radius in moving the object by step and centered in the coordinates of the target.

So let's start with the simplest method of targeting, which many probably used:

Direct guidance method


The principle is that at every step of the game cycle, the object must strive ("look") directly at the target:

image

In the image, I tried to show that the velocity vector does not always coincide with the line of sight, despite the fact that the object constantly “looks” at the target.

This is the most inefficient method among those considered, since with its help we get the longest and curved trajectory of the induced object. Also this method has the highest probability of breaking the guidance. However, this method is quite applicable to yourself - for example, if you do not want the player to have to strain very hard to get away from the rocket. Well, or you have only 30 seconds to implement.

Chase method


When you hover by this method at each step, the object must match the velocity vector and the direction to the target (line of sight).

image

Rumor has it that the chase method got its name because the dogs on the hunt pursue the goal in this way. The method is quite simple and gives slightly better results than the method of direct guidance.

I must say that if your object instantly gains and loses speed, then the two methods listed above are equivalent. Both of these methods have a modification: the object (velocity vector) is not directed directly at the target, but with a certain angle of lead. This allows you to reduce the curvature of the trajectory, and thus increase the efficiency of guidance. The first automatic-guided missiles used precisely these methods (for example, the American Sidewinder rocket used the chase method with a constant lead angle).

Parallel approach method


With this method, the object constantly seeks to maintain the angle of the line of sight of the target (ie, the line of the object-target).

image

If the target moves uniformly in a straight line, then our object will move along the most efficient trajectory - in a straight line, and the flight time to the target will be minimal. Thus, this method is the most effective of these. This is what I most often use, especially as the software implementation is much simpler than the implementation in real life (there are no parameter measurement errors, there is no mismatch between the calculated and real trajectories).

Proportional approach method


When you hover by this method, the angular velocity of the rotation of the velocity vector of the object will be proportional to the angular velocity of rotation of the line of sight of the target, ie:

image

In this case, the coefficient K can be chosen empirically (usually it is several units).

In fact, this method is a general method of guidance. After all, if we take the proportionality coefficient K for 1, then we get the chase method (the velocity vector will always be directed at the target), if K = ∞, then we get a parallel approach method.

Actually, this review methods guidance ends.

I hope the article will be useful, well, or at least not without interest.

Source: https://habr.com/ru/post/254485/


All Articles