hey i was wondering if anyone could help me im making a hover car and it slides around too much it also gos to far when the acelerator(space) isent pressed. dose anyone no howto fix this ive tryed a cuple of ways but they make it stop instantly? anyhelp would be apreciated hear is the script thanks :):
#pragma strict
var upforce=0.0;
var upforceidle=0.0;
var maxrotate=0.0;
private var speed : float = 10.0;
private var rotationSpeed : float = 10.0;
function Update ()
{
var hit : RaycastHit;
if (Physics.Raycast (transform.position, -Vector3.up, hit))
{
if (hit.distance < 1)
{
rigidbody.AddForce (Vector3.up * upforce);
}
else
{
rigidbody.AddForce (Vector3.up * upforceidle);
}
}
var gas : float = (Input.GetKey("space")?1.0:0.0) * speed ;
var torque : float = Input.GetAxis ("Horizontal") * rotationSpeed;
var stopping = 0 - gas;
rigidbody.AddRelativeForce (Vector3.forward * gas);
rigidbody.maxAngularVelocity = maxrotate;
if(Input.GetAxis ("Horizontal"))
{
rigidbody.AddRelativeTorque (0, torque, 0);
rigidbody.AddRelativeForce (-Vector3.forward * gas);
//rigidbody.velocity = Vector3.zero;
}
}