Day 107: Ladder System Part 1

Objective: Create a System to attach the player to a ladder and move up or down it.

Today will be about the Ladder. For this system when you reach the top the game automatically starts the climb up animation and set’s player’s position at the top.

To start we will need a ladder model. We got the model from FileBase.

We downloaded and only imported the ladder that we will use. We also use add a StartPos and EndPos empty objects, these will help out later. To get the right position for your character, there will be a lot of small adjustments you have to do based off the animation.

After we position the ladder in the world, we create a ladder script that will check for OnTriggerStay and then check for input from the player. This script will also have a transform variable for the starting position and end position.

Once we catch the players Input, we will call a method in the player script. This method will take in a vector3 and a Ladder variable. In the player script we will create this method. In this method we will assign the player’s position to the vector3 we get from the Ladder script. Next we will have a bool called _climbLadder and set it to true. Following that we will set the Animation bool, more on that tomorrow. Finally our _activeLadder variable will be assigned a ladder.

Now that we are on the ladder we can no continue to use our normal way of walking left and right. In Update we will check to see if _climbLAdder is true to climb a ladder and if not continue moving like normal.

In our ClimbLadder method we will create a local variable and assign it the Input of the Vertical Axis. Next is to set the direction to equal a new vector3 and only assign the y value to vertical. Next will be to assign the velocity to direction multiplied by playerSpeed. Finally use Character controller to move the player based off the _velocity multiplied by Time.deltaTime.

That is all to climb onto the Ladder and move up and down.

Next is to add our animations and parameters into the game. Like we have been let’s grab our animations from Mixamo. We will need a climbing animation and climb off animation.

I grabbed Climbing Ladder and Climbing To Top animations. We download both using FBX for Unity and with Skins.

Once we drag into Unity we will set the Rig to Humanoid and make a duplicate. Before moving on, I would like the animation to stop if the player lets go of the keys while on the ladder. To do this I have made another duplicate of the ClimbingLadder and named it ClimbingLadderIdle. With Idle selected I turned off Loop Time.

Once the duplicate is made we will drag into our Animator.

Now for our parameters. We will need a bool to know if we are on the ladder, a float to know if we are moving and finally one for climbing off ladder.

We will have transition lines from OffensiveIdle and Fast run to Climbing ladder Idle. Both will have the condition of ClimbingLadder is equal to true.

From ClimbingLadderIdle and ClimbingLadder we will have the conditions of speed is greater then .1 start climbing. Vise versa if less than .1 go back to Idle.

Finally, if climboffladder is true start the climbing to top animation.

We now have animations to go with the climbing off the ladder.

Tomorrow we will cover how to get off the ladder and to assign the players position to the ending of the Climb off Ladder point.

Thank you for reading and have a wonderful day!!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tyler Smallwood

Tyler Smallwood

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