Exemple #1
0
 /*
  * Called when the jump button is held down
  *
  * Triggers a ledge vault if a suitable ledge is in front of the player
  */
 public void JumpHold()
 {
     if (!vaulting && PlayerCollisionController.GetVaultHeight() > 0f)
     {
         StartCoroutine("PerformVault");
     }
 }
Exemple #2
0
    /*
     * Performs a vault to the height of the ledge in front of the player
     */
    private IEnumerator PerformVault()
    {
        vaulting = true;

        while (PlayerCollisionController.GetVaultHeight() > 0f)
        {
            // Get the force required to move the player up to the level of the ledge
            float force = Mathf.Sqrt(PlayerCollisionController.GetVaultHeight() * -2 *
                                     -GlobalGravityControl.GetGravityStrength());

            rb.velocity = transform.up * force;
            yield return(0);
        }

        vaulting = false;
    }