I´m making a ball game in 3D in JS but i have the problem that whenever my player goes down a hill etc. it gains
A LOT Speed which it shouldn´t.
How do i limit its max speed?
My script:
```javascript
**#pragma strict
var jumpHeight = 0.02;
static var jumpCount = 0;
var canJump = true;
var horizontalSpeed : float;
var verticalSpeed : float;
var maxSpeed : float;
function Update ()
{
if (Input.GetKey (KeyCode.W) && jumpCount == 0)
{
GetComponent.().AddForce (0, 0, 12 * verticalSpeed);
}
if (Input.GetKey (KeyCode.S))
{
GetComponent.().AddForce (0, 0, -8 * verticalSpeed);
}
if (Input.GetKey (KeyCode.A))
{
GetComponent.().AddForce (-11, 0, 0 * horizontalSpeed);
}
if (Input.GetKey (KeyCode.D))
{
GetComponent.().AddForce (11, 0, 0 * horizontalSpeed);
}
if (Input.GetKey (KeyCode.Space) && jumpCount == 0)
{
GetComponent.().AddForce(Vector3.up * jumpHeight, ForceMode.Impulse); jumpCount = 1;
}
}
function OnCollisionEnter (hit : Collision)
{
if(hit.gameObject.tag == “Floor”)
{
jumpCount = 0;
}
}**
```