Planning ballistic trajectories with air resistance for games

February 1, 2014 Math, Physics
Ballistic trajectories

Having enemies throw grenades or launch projectiles in games often requires some form of trajectory planning in order to find the best launch moment, speed and angle. When trying to take drag and wind into account as well, this process quickly becomes complex and inefficient.

The research paper below proposes a novel and practical approximation of 2D and 3D trajectories with drag and wind, which allows for very efficient planning.

Analytical Ballistic Trajectories with Approximately Linear Drag”, Giliam J. P. de Carpentier, International Journal of Computer Games Technology, vol. 2014, Article ID 463489, 13 pages, 2014. doi:10.1155/2014/463489. [Download PDF] [Additional resources]

This paper includes formulas and code snippets that can be used to easily calculate the initial velocity to hit any target given the initial position, the target position, the gravity, wind and drag constants, and

  • the time to target, or
  • another position to pass through (or to shoot exactly over an obstacle, for example), or
  • the top height, or
  • the launch slope, or
  • the slope to hit the target at, or
  • the arc height, or
  • the exact launch speed, or
  • with the least amount of speed possible (the way humans typically like to do it)

To demonstrate all this in practice, I'm currently working on a small demo project for Unity3D. It will expose all the above ways of plannings through composable planner behaviours attached to large turrets that can shoot at static targets, moving targets, and (experimentally) even over polygonal obstacles. More info will follow soon, but here's a little preview already.

Screenshot from the Unity3d demo project

Screenshot from the Unity3d demo project


Additional resources

  • The paper's two C++ algorithms but with improved spacing and color coding [PDF]
  • The paper's Figure 4 as an animated GIF [GIF]

Comments (4)

February 2, 2014

You did a really good job on the paper. Every scenario that one would need is clearly explained and accompanied with source code. Best of all, its written in C++.

My only dislike is probably due to my opinion so take it how every you see fit. But, when reading the source code in the paper is a little difficult due to there not being any spacing between comments and code.

February 2, 2014

Thanks! Spacing and color coding in the algorithms sadly got 'lost in translation' in the publishing process. I've added a link in the Additional Resources to a PDF containing the same code in the much more readable original layout for your convenience.

February 3, 2014

Thank you for releasing an easier to read version. Best of luck to all your future endeavors! ^_^

June 3, 2014

Great work! I'm also working on a similar project in Unity3D and I would really appreciate if you could share the project.

Leave a comment