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.