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!


πŸ‘¨β€πŸ’» As always, all code from this video is available 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


🧑 Believe in LlamAcademy's mission and have received value from the videos? Here's how you can show your support:

🌟 Patreon: https://www.patreon.com/llamacademy

🌟 YouTube Member: https://www.youtube.com/channel/UCnWm6pMD38R1E2vCAByGb6w/join or click the Join button on any video

πŸ“š Take my Unity ShaderGraph Course:

https://www.gamedev.tv/p/unity-shader-graph?affcode=45216_kuvg0bp7

πŸ‘• Get yourself some LlamAcademy merch: https://llamacademy.myspreadshop.com/

πŸ’Έ Use my Affiliate Link for Humble Bundles https://humblebundleinc.sjv.io/9g4ak4

πŸ’Έ Publisher Sale! 50% OFF an entire publisher's Assets! Publisher changes weekly! https://assetstore.unity.com/publisher-sale?aid=1101l9QvC (affiliate)

πŸ’Έ Save up to 50% on NEW Assets: https://assetstore.unity.com/?new_sale=true&orderBy=1&aid=1101l9QvC (affiliate)


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.