I Want to make movement feel smooth and responsive
void Update()
{
if (Input.GetMouseButtonDown(0) && MenuManger.MenuManagerinstance.GameState)
{
moveTheBall = true;
startMousepos = Input.mousePosition;
startBallpos = ball.position;
}
else if (Input.GetMouseButtonUp(0))
{
moveTheBall = false;
}
if (moveTheBall)
{
Vector3 mouseDelta = Input.mousePosition - startMousepos;
float sensitivity = 0.01f; // Adjust this value to control the sensitivity of the movement
// Set the new ball position directly based on the mouse movement
ball.position = new Vector3(
startBallpos.x + mouseDelta.x * sensitivity,
ball.position.y,
ball.position.z
);
// Clamp the ball position to stay within the desired boundaries
ball.position = new Vector3(
Mathf.Clamp(ball.position.x, -2.4f, 2.4f),
ball.position.y,
ball.position.z
);
}
}