My vehicle script rotates but doesn’t move forwards. Whats the problem with my code?
EDIT Still doesent work after removing spaces from name. What could i add to make it work?
var car : Transform;
var speed : float = 1.0;
var rotateSpeed : float = 3.0;
function Start() {
car.GetComponent("Drive Script").enabled = false;
}
function Update() {
if(Input.GetKeyDown("t"))
{
car.GetComponent("Drive Script").enabled = false;
}
if(Input.GetButtonDown("Action"))
{
car.GetComponent("Drive Script").enabled = true;
}
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
if (controller.isGrounded) {
// We are grounded, so recalculate
// move direction directly from axes
moveDirection = Vector3(0, 0,
Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection * speed;
}
}