Hi. I made this simple movement script but i have a problem : the character keeps accellerating. How can i set a “max speed” ? (I’m a total noob, don’t tell me too complicated stuff xD)
#pragma strict
public var Speed = 10;
function Update () {
if (Input.GetKey(KeyCode.A))
rigidbody2D.AddRelativeForce (Vector2(-1,0) * Speed);
if (Input.GetKeyUp(KeyCode.A))
rigidbody2D.AddRelativeForce (Vector2(0,0));
if (Input.GetKey(KeyCode.D))
rigidbody2D.AddRelativeForce (Vector2(1,0) * Speed);
if (Input.GetKeyUp(KeyCode.D))
rigidbody2D.AddRelativeForce (Vector2(0,0));
}