# Aircraft attack visualization for turn based strategy game.

This topic is 1748 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am trying to design an algorithm that will allow me to visualize to the player a fighter jet attacking another fighter jet in 3d with missiles then travelling to a final location in a turn based game. The player selects the target to attack and the final location of his plane and an animation should play that will show the plane move to attack the enemy then move into the final location.

I initially tried to solve this using waypoints and bezier curves. I would set a waypoint near the target with the tangent facing the target then another waypoint at the final location, the plane would travel at constant speed along the curve. It ended up working in some scenarios but there was a whole lot of edge cases and it proved difficult to get curves that didn't have sudden sharp changes in direction even when applying a bunch of heuristics to handle some of the edge cases in positioning.

I was recommended to try a more dynamic approach by just setting up waypoints and tangents but having the plane try to maneuver to match these whilst being constrained by its own speed/acceleration/roll/pitch/yaw e.t.c. There would be two states in the animation, attack target and move to final location. However I am sort of lost on how to approach getting the plane to maneuver intelligently to the correct positions, preferably the movement would be quite interesting as well to look at. There are a number of constraints as well I want to achieve.

- The plane rotation should end up parallel with the ground (y = 0)

- The plane starts at speed = 0 in the air

- The target never moves

- The plane shouldn't appear to collide with the target (it should maneuver out of the attack path as soon as it fires its missiles)

Any pointers or ideas on how to achieve this would be greatly appreciated.

##### Share on other sites

Not sure what the parameters of your game are, but can it be simplified by just 1) launching missiles towards target and 2) moving plane towards final position?  Does the plane *have* to point at the target first?  Most modern planes can attack a target without pointing directly at it.

##### Share on other sites

I think you could probably use a variation of this:http://joshv.itburns.net/RadialAttempt.html,  If that link doesn't work for you, you can try looking at SteamBirds to see how their movement works, though yours will be slightly more complicated than theirs.  (they only have the planes move on one curve at a time)

What that is doing, is using Dubin's Curves to travel from waypoint to waypoint.  Each waypoint has a specified direction the object needs to face at the end of the waypoint, and is restricted by the turn radius of the object.  You're probably not going to have nearly as crowded of a grid, in fact you might not even have any collision at all, unless your planes are flying at low altitude and can't go through mountain tiles or something, which would simplify things greatly.  You'd end up with one Dubin's Curve to attack the target, and another for the plane to reach it's final destination from that attack location.

EDIT:  You could also go nuts and implement a bunch of 3d plane maneuvers and try to match those to a path as well.  Like an Immelman Turn, etc.  That's probably a bit much, depending on your game.

EDIT:  For a turn based game, I wouldn't recommend the approach of setting waypoints and having the plane use physics to try to reach them, as what happens if the plane can't make it to a waypoint, or to the attack point?  You'd have to fudge things, and then you'd probably end up with something similar to the curve problem of unrealistic looking moves.

Edited by ferrous

##### Share on other sites

Not sure what the parameters of your game are, but can it be simplified by just 1) launching missiles towards target and 2) moving plane towards final position?  Does the plane *have* to point at the target first?  Most modern planes can attack a target without pointing directly at it.

They could also just have some sort of limited attack vector, as long as the plane is somewhere in front of the target, say a 90 degree cone or something, just to avoid missiles that shoot backwards or sideways.  Though that's probably not impossible either, by either giving the missiles either a tight turn radius, or having them just detach then rotate towards the target, then ignite their engines. (Sort of like the Half-Life 2 missile launcher does)

Edited by ferrous

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 28
• 16
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
634112
• Total Posts
3015580
×