My journey becoming a Unity game developer: 2.5D Infinite Runner-Ledge Grab System-Pt1

Rhett Haynes
4 min readJan 25, 2022

--

Objective: Create a Ledge Grab Checker which will be attached to the Player. Also, download a Hanging Idle animation which will be used to position the Ledge Grab Checker to the Player.

Player with a Ledge Grab Checker attached to check for any collisions with ledges.

Let’s begin by downloading a Hanging Idle animation from Mixamo. Make sure to set the Format to FBX for Unity, and set Skin to With Skin. The other setting can be left to their default.

Downloading a Hanging Idle animation from Mixamo.

When download is finished, place the Hanging Idle animation into the Model’s FBX folder. Select the Hanging Idle animation, go to Rig in the Inspector, change Animation Type from Generic to Humanoid and click Apply.

Change Hanging Idle animation from Generic to Humanoid.

Inside the Hanging Idle animation, find the animation itself which has a triangular shape icon beside the name of the animation which in this case is Hanging Idle. Select the animation, duplicate it with CTRL-D, and drag the new animation copy into the Animations folder.

Duplicate Hanging Idle animation created.

With the new Hanging Idle animation still selected, turn on Loop Time as we want the Idle animation repeatedly playing. Also, turn on Bake into Pose for the Root Transform Rotation, Position(Y), and Position(XZ) as this will keep the Root of the animation Mixamo created from controlling the character’s movement itself.

Root Transforms Baked into Pose and Loop Time turned on.

Drag the Hanging Idle animation into the Player’s Animator, and create a Transition between Any State to Hanging Idle. Then in Parameters, create a Trigger name LedgeGrab which will make the Player’s Hanging Idle animation play when the player grabs a ledge.

Hanging Idle animation added to the Animator, transitioned and Ledge Grab Trigger created.

Click on the transition arrow connected between Any State->Hanging Idle. Has Exit Time should be turned off, and in Conditions select LedgeGrab. This will automatically go from True when the Hanging Idle animation is playing to False when the animation isn’t playing. Play the game and turn on the LedgeGrab Trigger to see the animation playing.

Transition from Any State to Hanging Idle with Ledge Grab Trigger Condition set.

Select the Player game object, right-click on it and create a new 3D Cube naming it Ledge Grab Checker. Play the game and turn on the Ledge Grab Checker to have the Player in its Hanging Idle position. Adjust the Scale of the Ledge Grab Checker to make the shape of the cube sort of a 2 by 4 look. Move the Ledge Grab Checker up to the Player’s hands so that the Player looks like they’re hanging from Checker object.

Ledge Grab Checker created for the Player, and placed along their hands.

With the game still in Play Mode, to keep the adjustments we made to the Ledge Grab Checker, just drag the Player game object into the Prefabs folder. Stop playing the game, delete the Player game object in the Hierarchy, and drag the Player prefab object into the Hierarchy instead. We will see the Player hanging from the Ledge Grab Checker when the game isn’t playing. Then when we play the game, the Player will release from the Ledge Grab Checker object into its Standing Idle animation with the Ledge Grab Checker object above its head following them wherever they go.

Player prefab now has the Ledge Grab Checker attached to them above their head.

Next time we will work on the Player being able to grab the ledge using a Ledge Checker object.

--

--

Rhett Haynes
Rhett Haynes

Written by Rhett Haynes

Learning to become a Unity game developer.

No responses yet