// Update is called once per frame.
 void Update()
 {
     // If the player is allowed to jump down...
     if (canJumpDown)
     {
         // Get the vertical input.
         float v = Input.GetAxis("Vertical");
         // If the vertical input is equal to -1 (moving down)...
         if (v == -1)
         {
             // If the player isn't grounded...
             if (!playerScript.grounded)
             {
                 // ... make sure the player falls through the platform.
                 JumpDown();
                 // Or else if the platform is the top of a ladder...
             }
             else if (platform.topOfLadder)
             {
                 // ... disable the collisions (no jumping).
                 platform.DisableCollisions();
                 // Or else...
             }
             else
             {
                 // ... get the jump input.
                 bool jump = Input.GetButton("Jump");
                 // If the jump button is being pressed...
                 if (jump)
                 {
                     // ... make sure the player knows he can jump down.
                     playerScript.jumpDown = true;
                     // And then: jump!
                     JumpDown();
                 }
             }
         }
     }
 }
Exemple #2
0
 // Function to disable all collisions between the platforms and the player.
 void DisableCollisions()
 {
     // Disable the collisions.
     platform.DisableCollisions();
 }