In this tutorial repository and associated video you will learn how to set up OffMeshLinks via the NavMeshLink component to add ladders into your game! NavMeshAgents will correctly position themselves, mount the ladder, climb the ladder, and dismount the ladder in a relatively smooth sequence.
WARNING: This repository does not ship with ladder animations. In the tutorial video I am using Protofactor's Ultimate Animation Collection (affiliate link) ladder movement. Any of your preferred ladder animations will work but may require some tweaks.
The following assumes you have skipped the tutorial video altogether.
- Open the
Assets/Scenes/SampleScene.unityin a modern Unity Editor (Built with Unity 6). - Import your preferred ladder animations. If you import Protofactor's, the Animator will be automatically configured.
- Attach ladder bottom/top mount/dismount clips to the
LadderAnimationInfoonThe DudeGameObject- Update the Animator Controller on
The Dudeto use your appropriate bottom/top mount/dismount and climb up/down clips. The Animator expects 6 clips.
- Update the Animator Controller on
- Click play
- Send
The Dudenear the ladder by left clicking. - Send
The Dudeto the top of the ladder by left clicking on top of the structure. - Send
The Dudeto the bottom of the ladder by left clicking back on the floor.
AgentLinkMover.cs - a heavily modified version of what Unity provided as a demo script with the Navigation Components back in 2019. This is how the scripted ladder climbing sequence is performed.
LadderAnimationInfo.cs - a struct to hold the clips so we don't have to introspect the Animator and can wait the appropriate amount of time before lerping the climb up/down position.
PlayerMovement.cs - Synchronizes the Root Motion Animation & NavMeshAgent as done in AI Series 42. Also listens for mouse clicks to set the NavMeshAgent destination.
- AI Series Part 1 - Left Click to Move a NavMeshAgent & Setting up the Navigation Components (installation can be done via Package Manager now).
- AI Series Part 2 - Introduction to NavMeshLinks
- AI Series 17 - AgentLinkMover implementation
- AI Series 42 - Root Motion & NavMeshAgents
- 8 Inverse Kinematic Solutions Compared - Some Unity IK Solutions compared and recommended.
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 https://patreon.com/llamacademy to show your support.
- YOUR NAME HERE!
- YOUR NAME HERE!
- Mustafa
- Ivan
- Iffy Obelus
- Snedden
- YOUR NAME HERE!
- AudemKay
- Matt Sponholz
- Tarik Ahmed
- Elijah Singer
- Bruno Bozic
- Josh Meyer
- Ben
- Christiaan van Steenwijk
- StrangeSwelter
- ChimeraDev
- Lukas Wolfe
- Jason Hansen
- angell
- Warspawn
- Ewald Schulte
- Wendy Whitner
- Ralevum
- YOUR NAME HERE!
Interested in other AI Topics in Unity, or other tutorials on Unity in general?
- Should work on any modern version of Unity. Built with Unity 6.
- Navigation Components - Can be installed from the Package Manager in modern versions of Unity.
