Climb that Ladder

Hi Cork_Emperor,

Welcome to our community! Enjoy the course and happy coding! :slight_smile:

The ClimbLadder() method gets called each frame in the Update() method. The first code in that method is:

if (!myFeetCollider.IsTouchingLayers(LayerMask.GetMask("Climbing")))
{
    // code

    return;
}

This means: If the feet collider is not touching the “Climbing” layer, the method gets terminated. That’s what the return; keyword does.

If the feet collider is touching the “Climbing” layer, the code after the if-block gets executed. And that’s the code which allows us to move the player along its y-axis:

Vector2 climbVelocity = new Vector2 (myRigidbody.velocity.x, moveInput.y * climbSpeed);
myRigidbody.velocity = climbVelocity;

Is this what you wanted to know?


See also: