private void FixedUpdate() { float horizontal = vJoystick.HorizontalMovement(); Vector2 currentVelocity = rBody2D.velocity; if (horizontal * currentVelocity.x < maxSpeed) { rBody2D.AddForce(Vector2.right * horizontal * moveForce); } if (Mathf.Abs(currentVelocity.x) > maxSpeed) { rBody2D.velocity = new Vector2(Mathf.Sign(currentVelocity.x) * maxSpeed, currentVelocity.y); } if (horizontal > 0 && !facingRight) { FlipPlayer(); } else if (horizontal < 0 && facingRight) { FlipPlayer(); } if (jump) { rBody2D.AddForce(new Vector2(0f, jumpForce)); jump = false; } }