Hit Moving Targets with Projectiles | AI Series Part 41




Published: 30 Aug 2022

In this Unity tutorial, learn how to make your AI throw accurate projectiles at stationary targets given only a maximum allowable throw velocity. You can also learn how to make the AI be pretty dang good at predicting where the player will be and hitting them while they are moving, still with only a maximum allowable throw velocity. No hard coded heights, just accurate throws!


I spend a lot of the video covering how the math works out so you can understand the process we follow to get to this result, as well as covering the equations we're using so you can take this implementation and enhance it to further suit your game's needs. Of course, if this is "good enough" for you, feel free to take it off the shelf. If you're looking for even more accurate predictions or throwing over/under obstacles, don't worry! I also cover what else you need to do to take those use cases into consideration!


๐Ÿ”ถ ALL THINGS LlamAcademy now available at: https://llamacademy.dev/support including latest tutorials, courses, ways to support, and more! Check it out ๐Ÿ™‚

๐Ÿ‘จโ€๐Ÿ’ป Get the FULL FREE PROJECT on GitHub: https://github.com/llamacademy/ai-series-part-41

๐Ÿท๏ธSave 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: https://www.jetbrains.com/store/?section=personal&billing=yearly


๐Ÿ“šResources๐Ÿ“š

๐ŸŸ  Projectile Motion Wikipedia (equations): https://en.wikipedia.org/wiki/Projectile_motion#Angle_%CE%B8_required_to_hit_coordinate_(x,_y)

๐ŸŸ  Kinematic Equations Source: https://www.physicsclassroom.com/class/1dkin/Lesson-6/Kinematic-Equations

๐ŸŸ  Projectile Trajectory Video: https://youtu.be/8mGZBYsSXcQ


Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.


Connect on Social Media

Some links may be affiliate links, which at no additional cost to you, gives LlamAcademy a small portion of the purchase.