# Rigidbody movement

Hi,
I have a little problem (Not for me but absolutely for you) . My player is a ball/Sphere and it has 500 movement speed , now in a big plane platform when i move ball horizontally or vertically directions then if i press keyboard key for long time it will make it speed faster and more faster not limited . Can you please tell me how can i limit my speed for a long distance .

Here is how i am moving my player .

``````float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal,0.0f,moveVertical);

rigidbody.AddForce (movement * speed * Time.deltaTime);
``````

Make maxSpeed variable:
float maxSpeed = 10f;

and use this:

``````float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal,0.0f,moveVertical);
rigidbody.AddForce (movement * speed * Time.deltaTime);

Vector3 currentSpeed = rigidbody.velocity;
currentSpeed.x = Mathf.Clamp(currentSpeed.x, -1f*maxSpeed, maxSpeed);
currentSpeed.y = Mathf.Clamp(currentSpeed.y, -1f*maxSpeed, maxSpeed);  //not important
currentSpeed.z = Mathf.Clamp(currentSpeed.z, -1f*maxSpeed, maxSpeed);
rigidbody.velocity = currentSpeed;
``````