Published: August 14, 2021
6
25
195

This is by far the best airplane formation flight I've ever been able to figure out. Long thread below for how it works! #gamedev #screenshotsaturday

In hindsight, this stuff seems obvious, but this is a problem I've been trying to solve for years and it wasn't until the most recent time I was playing around in Jane's Fighters Anthology that something clicked.

#1 Following aircraft MATCH the bank angle of the lead! Planes can't just yaw and slide their way into formation like spaceships. They need to smoothly bank in order to turn. How to predict the precise bank needed to remain in place is very hard, so just copy it from the lead!

This isn't perfect, but it gets the planes close enough that they can use yaw and pitch inputs to make the minute corrections necessary. This lets them effectively "predict" the upcoming turn, since the lead will need to bank before they can make their turn.

#2 Fly towards a distant point, but use the REAL point for throttle. One of the biggest difficulties of formation flight is throttle management to stay in position. The naive solution simply tells a plane to fly to A, but this has two major drawbacks!

Image in tweet by Why485 🐀

The plane might have difficultly actually reaching point A, and so they'll always lag behind a correct formation. This can be compensated for by offsetting the target forwards, but that only shifts the problem, and how far they lag depends on speed.

Image in tweet by Why485 🐀

The other problem this creates, is that if the AI gets too close to the target position, their steering behaviors become extremely sensitive and you get "pilot" induced oscillations. If they pass the point, then they'll want to do a flip and waste time trying to catch up again.

The trick is to sort of combine the two hacks. Tell the plane to fly towards point B. In my case it's actually offset by 200 meters ahead of the target point. While the plane flies to point B, tell the THROTTLE, to target point A, the real target point.

Image in tweet by Why485 🐀

The trick is to sort of combine the two hacks. Tell the plane to fly towards point B. In my case it's actually offset by 200 meters ahead of the target point. While the plane flies to point B, tell the THROTTLE, to target point A, the real target point.

This gives the AI a pretty sizeable error to run ahead before they hit the same oscillations and need to totally reset. By passing the true target point (A) the throttle will know to back off, but since the stick is aiming for an imaginary point head, the plane simply falls back.

Those are the two tricks that did it for me. This is skipping over a lot of matrices and transformations to generate formation points, along with the physics and highly tuned (5 channel!) PID controllers to fly the planes themselves, but I hope the principles came across 🙏

@Why485 ...wow. congrats on getting it.

@Why485 This is an awesome achievement, and your techniques are applicable in other places regarding control, thanks for sharing!

@Why485 The turns into lead look really good. Turns away from lead need to rotate about leads axis ~welded wing. The wingman can’t see through his own wing and couldn’t judge when to roll out of the turn. If the formation was spread out it doesn’t matter too much.

@Why485 Thank you for the thread!

Share this thread

Read on Twitter

View original thread

Navigate thread

1/15