Is there some reason why Rick write code like this:
{
if (!myCollider.IsTouchingLayers(LayerMask.GetMask("Climbing")))
{
return;
}
Vector2 climbingVelocity = new Vector2(moveInput.x, moveInput.y * climbingSpeed);
myRigidbody.velocity = climbingVelocity;
}
instead of
void ClimbLadder()
{
if (myCollider.IsTouchingLayers(LayerMask.GetMask("Climbing")))
{
Vector2 climbingVelocity = new Vector2(moveInput.x, moveInput.y * climbingSpeed);
myRigidbody.velocity = climbingVelocity;
}
}
Is this for optimization or what is reason for writing longer code?