// --------------------------------------------------------------------------------- // CHARACTER CONTROLS // --------------------------------------------------------------------------------- // Design flaw - player can walk off ledge, falling won't trigger until the player "jumps" // Rework required private IEnumerator Jump() { bool isFalling = false; // Start jump isJumping = true; yield return(StartCoroutine(JumpAnimation())); rigBody.AddForce(Vector3.up * jumpHeight, ForceMode.VelocityChange); // Wait until falling while (!isFalling) { yield return(new WaitForSeconds(0.5f)); if (!PlayerUtils.CharacterFalling(lastYposition, transform.position.y)) { isJumping = true; isFalling = true; } } StartCoroutine(FallAnimation()); }