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.