// Stick to ladder. void Stick() { // Put the Ladder class of the ladder in the ladder variable. ladder = hitLadder.GetComponent <Ladder>(); // Make sure the player is considered on a ladder. player.OnLadder(); // If the player is allowed to jump... if (ladder.allowJump) { // ... if the player is allowed to double jump... if (ladder.allowDoubleJump) { // ... reset the amount of jumps that can be performed. player.ResetJumps(); // Or else... } else { // ... set the total jumps allowed to 1. player.SetJumps(1); } // Or else... } else { // ... set the total amount of jumps to 0. player.SetJumps(0); } }
// Function to perform the wall jump. Resets several variables and performs a jump. void PerformWallJump() { stuckToWall = false; wallRunning = false; wallSliding = false; Unstick(); isWallJumping = true; if (wallJump.allowDoubleJump) { player.ResetJumps(); } else { player.SetJumps(1); } player.Jump(); }