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.