when i enter the script(below) to move a car right now a box it says that:
unknown identifier ‘transform’
unknown identifier ‘speed’
unknown identifier ‘turnSpeed’
unknown identifier ’ Transform’
the script i used is :
#pragma strict
function Start () {
var speed : float=5;
var turnSpeed : float=180;
}
function Update () {
var steer=Input.GetAxis(“Horizontal”);
var gas=Input.GetAxis(“Vertical”);
if (gas!=0)
var moveDist=gasspeedTime.deltaTime;
var turnAngle=steer * turnSpeed * Time.deltaTime * gas;
For global variables (variables that are used through all the script, and in different functions of the script), they need to be declared outside of a function :
var myFloat : float = 1.25;
function Start()
{
myFloat += 12.34;
}
And this line :
Trasform.rotation.eulerAngles.y+=turnAngle;
2 problems, the spelling, and when referencing the component this way , it is a lower-case t in transform
Capitol T for Transform is only used when typecasting a variable :
var myTransform : Transform;
For further help, please format your code. You can do this by highlighting all your code, then clicking the 10101 button at the top of the edit window.
You need to set your variables out of the Start function:
var speed : float = 5;
var turnSpeed : float = 180;
var MoveDist;
var turnAngle;
function Update(){
var steer = Input.GetAxis(“Horizontal”);
var gas = Input.GetAxis(“Vertical”);
if(gas!=0){
var MoveDist = gas * speed * Time.deltaTime;
var turnAngle = steer * turnSpeed * Time.deltaTime * gas;
Transform.rotation.eulerAngles.y+=turnAngle;
Transform.Translate(Vector3.forward*moveDist);
}
}
but when i do that the controls become in verse and the car wheels do not rotate to change the direction can u please suggest a script to make it right.
i am a beginner so!