private void CheckIfCanJump() { if ((slowMotionJumpAvailable || grounded) && !notifiedJump) { OnCanJump.Invoke(); notifiedJump = true; } }
public void Jump(float Height) { float initialVelocity = (float)Math.Sqrt((-2 * Physics.gravity.y)); //(Height+(0.5f*Physics.gravity.y*jumpDuration*jumpDuration))/jumpDuration; Vector3 UpwardVelocity = _characterGameObject.transform.up * initialVelocity; Vector3 GroundVelocity = _previousVelocity; GroundVelocity.y = 0f; Vector3 FowardVelocity = GroundVelocity; JumpVelocity = UpwardVelocity + FowardVelocity; _canJump = false; OnCanJump?.Invoke(false); }
private void CalculateCanJump(bool TryingToJump) { if (TryingToJump == false) //released/up { if (_canJump == false) { _canJump = true; OnCanJump?.Invoke(true); } } else { if (_canJump == true) { OnGroundContactLost(); _state = LocomotionState.Jumping; OnStateChange?.Invoke(_state); currentJumpStartTime = Time.time; Jump(_jumpHeight); } } }