Show Any Projectile's Trajectory in Unity with Simple Math & a Line Renderer #shorts




Published: 07 Jul 2022

Full Tutorial on YouTube: https://youtu.be/8mGZBYsSXcQ


Need to show the path of a projectile? Not paying attention in Physics catching up to you? No problem! Learn how to draw the trajectory of a projectile would take using a LineRenderer and one of those pesky physics formulas you said you'd never use again! Show a visualization of where those objects will go!


We're using a grenade in this case, but it can be applied to cannon balls, bullets affected by gravity, throwing a banana, or any other projectile!


If you're checking out the GitHub Repository below, make sure to get the Unity Particle Pack and head over to Mixamo and pick up the "Throw Object" animation (tip: trim it down to skip the pick-up section) and add it to the Animator with an upper body avatar mask.


As always, all code from this video is available on GitHub: https://github.com/llamacademy/projectile-trajectory


📱 Let's stay connected

YouTube: https://youtube.com/c/LlamAcademy

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

Facebook: https://facebook.com/LlamAcademyOfficial

Twitter: https://twitter.com/TheLlamAcademy

TikTok: https://tiktok.com/@LlamAcademy

Instagram: https://instagram.com/LlamAcademy


----


Believe in LlamAcademy's mission and have received value from the videos? Consider becoming a Patreon supporter: https://www.patreon.com/llamacademy


----

Most tutorials come from knowledge gained making https://survival.llama.software Llama Survival - a top-down zombie survival shooter for Android and iOS.

I also have some Unity Assets (affiliate link): https://assetstore.unity.com/publishers/22409?_aid=1101l9QvC


#unitytutorial #tutorialtuesday #gamedev #tutorial #unity #llamacademy #gamedevelopment


00:45 Scene Overview

01:51 Show Visualization in GrenadeThrower.cs (with math explanations)

06:07 Hooking up references in the editor

06:47 Demo 1 - See the need for Raycasting

07:51 Prevent Line From Going Through Walls in GrenadeThrower.cs

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.