private void FixedUpdate() { if (controller.collisionInfo.above && velocityRelative.y > 0 || controller.collisionInfo.below && velocityRelative.y < 0) { velocityRelative.y = 0; } Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); //jump if (Input.GetKeyDown(KeyCode.Space) && controller.collisionInfo.below) { velocityRelative.y = jumpVelocity; } //smooth x movement float targetVelocityX = input.x * moveSpeed; //velocityRelative.x=targetVelocityX; velocityRelative.x = Mathf.SmoothDamp(velocityRelative.x, targetVelocityX, ref velocityXSmoothing, (controller.collisionInfo.below ? accelerationTimeGrounded : accelerationTimeAirborne)); velocityRelative.y += Gravity.GetInstance().gravity.y *Time.deltaTime; controller.Move(velocityRelative * Time.deltaTime); }