public void FixedUpdateController() { //Run initial mover ground check; mover.CheckForGround(); //If character was not grounded int the last frame and is now grounded, call 'OnGroundContactRegained' function; if (isGrounded == false && mover.IsGrounded() == true) { OnGroundContactRegained(lastVelocity); } //Check whether the character is grounded and store result; isGrounded = mover.IsGrounded(); Vector3 _velocity = Vector3.zero; //Add player movement to velocity; _velocity += CalculateMovementDirection() * movementSpeed; //Handle gravity; if (!isGrounded) { currentVerticalSpeed -= gravity * Time.deltaTime; } else { if (currentVerticalSpeed <= 0f) { currentVerticalSpeed = 0f; } } //Handle jumping; if ((characterInput != null) && isGrounded && characterInput.IsJumpKeyPressed()) { OnJumpStart(); currentVerticalSpeed = jumpSpeed; isGrounded = false; } //Add vertical velocity; _velocity += tr.up * currentVerticalSpeed; //Save current velocity for next frame; lastVelocity = _velocity; mover.SetExtendSensorRange(isGrounded); mover.SetVelocity(_velocity); }