Climbing Idle Animation

Climbing Idle

For my game I wanted to have two separate climbing animations. One for when my character is sitting stationary on the ladder, and another when they’re actually climbing. This way, it feels more alive than simply freezing the climbing animation when movement has stopped. It took a little trial and error to get it working just right so I figured I’d share my method.

private void ClimbLadder()
    {
        if (!myCollider.IsTouchingLayers(LayerMask.GetMask("Ladder")))
        
        {
        myAnimator.SetBool("Climbing", false);
        myAnimator.SetBool("ClimbingIdle", false);
        myRigidBody.gravityScale = gravityScaleAtStart; 
        return; }

        myAnimator.SetBool("Climbing", true);
        float controlThrow = Input.GetAxis("Vertical");
        Vector2 climbVelocity = new Vector2(myRigidBody.velocity.x,
        controlThrow * climbSpeed);
        myRigidBody.velocity = climbVelocity;
        myRigidBody.gravityScale = 0f;

        if (myRigidBody.gravityScale == 0 && Input.GetAxis("Vertical") == 0)
        {
            myAnimator.SetBool("ClimbingIdle", true);
        }
        if (myRigidBody.gravityScale == 0 && Input.GetAxis("Vertical") != 0)
        {
            
            myAnimator.SetBool("ClimbingIdle", false);
        }

When you’re setting up your animator, you’ll want to set it up like this:

This way once you hit a ladder, it’ll go straight into your climbing animation, then swap between climbing and climbing idle depending on wether or not you’re moving, and both will be set to false when you leave the ladder so you can can transition back to idling and walking from either state.

2 Likes

Your solution looks amazing!

If you are looking into more complicated animations and tricks, I suggest you dig a little into this:

Blends trees are an amazing tool to create amazing animations, also, I suggest looking into this:

If you click on that plus button it adds a new layer, with those layers you can do what you just did but with a single line of code, really useful tool.

I’m just pointing the tools out, don’t know if any of this will be covered during the course, so maybe you’ll want to finish it first before digging deep into the Animator’s tools and options.

1 Like

Thanks for the tips! I definitely need to a deep dive into learning the animator controller because there seems to be a lot of functions it’s capable of that I don’t even know.

Privacy & Terms