In this tutorial repository and accompanying video you will learn how to knock back NavMeshAgents using Physics & Forces!
This repo uses the Scriptable Object Gun System as of branch part-14
to handle shooting.
This was then modified to add knockback. There's nothing specific to this system required to make the knockback effect work. It just was a launching point to allow this to focus on the knockback instead of implementing a bunch of systems from scratch.
- Import Unity Particle Pack (free)
- Click play!
Everything should be working from there.
While I highly recommend you check out the video for a complete understanding, I also understand that's not everybody's cup-of-tea. Here are the key classes if you just want to explore:
IKnockbackable.cs
- Interface to allow arbitrary objects to be knocked backEnemyMovement.cs
- ImplementsIKnockbackable
to handle how to get knocked back.KnockbackOnCollision.cs
- Applies force toIKnockbackable
sOnCollisionEnter
GunScriptableObject.cs
- Applies force toIKnockbackable
s when bullets make impactKnockbackConfigScriptableObject.cs
- Houses the configuration for the knockback effect as well as calculating the
This tutorial is Sponsored by Southern New Hampshire University. If you're interested in leveling up your gamedev skillset, consider getting an affordable, accredited degree in Computer Science or Game Design & Development from SNHU. You can go to https://snhu.edu/llamacademy to see what the current average annual salary for a game developer programmer is and learn how you can get started!
Have you been getting value out of these tutorials? Do you believe in LlamAcademy's mission of helping everyone make their game dev dream become a reality? Consider becoming a Patreon supporter and get your name added to this list, as well as other cool perks. Head over to the LlamAcademy Patreon Page, join as a YouTube Member, or even become a GitHub Sponsor to show your support.
- YOUR NAME HERE!
- YOUR NAME HERE!
- Ivan
- Reulan
- Iffy Obelus
- Perry
- Mustafa
- YOUR NAME HERE!
- Trey Briggs
- Matt Sponholz
- Dr Bash
- Tarik
- Sean
- Elijah Singer
- Bruno Bozic
- Josh Meyer
- Ewald Schulte
- Andrew Allbright
- AudemKay x2
- Claduiu Barsan-Pipu
- Ben
- Christian Van Sttenwijk
- Joseph Janosko
- Chimera Dev
- Wendy Whitner
- Lukas Wolfe
- YOUR NAME HERE!
Interested in other Topics in Unity?
- Requires Unity 2022.3 LTS or higher.
- Universal Render Pipeline
- Unity Particle Pack
Some links in this readme may contain affiliate links which, at the time of purchase, at no additional cost to you, gives me a small portion of the purchase.