Hi, all,
I am using the following script to accelerate my player object. It works very well, except I would like to dial back the top speed which is too fast. The drag var only seems to slow the object once the button is off. Could anyone point me to the solution?
Thanks,
Greg
var target : Rigidbody;
var pedalImage : Texture2D;
var acceleration : float = 20;
var drag : float = 1.0;
private var accelerate : boolean = false;
function FixedUpdate()
{
if (accelerate)
{
target.drag = 0;
target.AddRelativeForce(0,0,acceleration);
}
else
{
target.drag = drag;
}
}
function OnGUI()
{
if (GUI.RepeatButton (Rect (380,220,100,100), pedalImage))
{
accelerate = true;
}
else
{
accelerate = false;
}