Journal 87 — Unity 2.5D Platformer, Add Ladder and Animation

Objective: To add a ladder and player animation for using the ladder

In this article, I will go over adding a ladder to the basic platformer level, including the player animations.

The basic approach is as follows:

  • Find or create animation assets and add to scene
  • Find or create model assets and add to scene
  • Add triggers for using ladder and exiting ladder
  • Add transitions for animations
  • Add C# script for ladder
  • Update Player script to control movement and animations

First, we can go to Mixamo and pick out some basic animations for grabbing and getting on the ladder, the climbing action, and exiting at the top of the ladder.

Next we can look for some ladder assets or possibly make our own.

Here is one of the selected ladders added to the scene.

We can add the animations in Unity after dragging each .FBX file from Mixamo into the Animations folder.

We can change the Rig to Humanoid, select “Apply”, then with the animation file selected, we can duplicate it (Ctrl+D) to make it editable.

Now we can update the ladder game object with a RigidBody, trigger, and empty game objects for the top and exit of the ladder. You may need to adjust the trigger position and size to better show the player grabbing the ladder, and also the point of exit.

We can add several transitions to the Animator for the Idle and Running conditions to climb the ladder, and get off the ladder at the top.

In the new Ladder C# script, we want to add behavior for OnTriggerEnter when the player triggers the ladder to climb on, OnTriggerExit when the player exits the ladder, and return the exit locations at the top of the ladder.

In the Player script, we can add two public functions to activate the animations to climb the ladder. In the Player Update method, we can add the ladder climbing movement based on the vertical input. We can also include a slight rotation of the player that coordinates with the climbing animation.

See the results.

Next we can update the exit action. In the ClimbUpLadderBehaviour script, we can add an override OnStateExit function to show the final animation of exiting the ladder and the transform.position on the next platform.

Here are the final results.

Thank you for your time!



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
Chris Nielsen

Chris Nielsen

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.