Day 17: Animating the player and setting up our Ledge Grab System

Philip Johnson
3 min readJul 17, 2021

Objective: To kick off the ledge grabbing system for our Player script and to have the Player model perform the correct animations during gameplay.

For this stage in the development of a complete 2.5D platformer controller setup, we will now begin work on the ledge grabbing system. The ledge grabbing system itself will rely heavily on the driving force of our animations so for that to happen we need a player model that has animations.

To set this up we need a model with animations that will be the child of the model transform, which is a child of the player object. This is set up because while a character is climbing up from a ledge, we will have the model play the animation of climbing up without affecting the position of the player object. The animation itself will call an event that will trigger the change in the player object’s position from hanging on the side of a ledge to standing upright on the platform we landed on.

For this segment I actually re-wrote the player controller from scratch to simplify things and only worry about the ledge grabbing mechanic. In this script we will hook into the animator component of the character model. We will use the GetComponentInChildren<Animator>() method to find the Animator so that we can manipulate it with code.

Now that we’re hooked into the animator we can control it’s properties through our code. In the update loop we will use many of the same variables set up in the first version of our player script. We have a bool for_isJumping so that we can trigger the “Jump” boolean parameter in the Animator controller. We use this paramter to transition into either a running jump animation or a straight vertical jump animation.

The speed paramter of our player script will help us control our running animation. If our player is in the air and then lands on the ground, _isJumping will be set to false which will trigger the Animator controller to switch back into the idle state. This can be seen in the gif below.

In the update loop we handle the rotation of our character based off of the horizontal axis input. For this I will use something called a Ternary Operator to assign either a value of 0 or 180 to the Y axis of our players LocalEurlerAngles(a fancy term for rotations in 3D).

The animated player controller now has a foundation to stand on and we can continue with the ledge grabbing mechanic. The effect can be seen in the gif above.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Philip Johnson
Philip Johnson

No responses yet

Write a response