Day 108: Ladder System Part 2

Tyler Smallwood
3 min readMar 21, 2022

Objective: Climb up the ladder and automatically get off at the top.

Today we will discuss how the ladder will automatically start the animation to get the player off the ladder and onto the next platform.

Yesterday we set up the Ladder script. Now we will need another script to exit the ladder. In this script we will use OnTriggerEnter to start the movement from the ladder.

Under the Ladder game object we will have a cube object with the mesh renderer disabled, also with Box Collider set as IsTrigger. This is where the script will be.

Before we add anything else to this, we will need something to call to start the process of getting off. Back in the Player script we will create a method called PlayerGetOffLadder. In here we will disable the character controller and call an animation bool. More on the animation tomorrow.

Now our animation will run and we will need set the position of the player at the top when the animation ends. To do this we will create a Behaviour script on ClimbingToTop animation.

In this Behaviour script we will un comment OnStateExit and call the player script. In this we will call a method from the player script.

In the player script we will create another Method called PlayerOffLadder. In this method we will set the players position to EndPos of the ladder. Next is to set the climb ladder to false, re-enable the character controller and set the climbing ladder animation bools to false.

Now to get the position from the active ladder. In the ladder script we will create a return type method that returns a vector3. We will return the EndPos that we have assigned.

Now in the scene view, we can see where the EndPos is located at. This will need adjustment based of the ending position of the animation. The animation that was picked for you could have a different end position for me.

That is the end of the Ladder behaviour.

Thank you for reading and have a wonderful day!

--

--

Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer