- Home /
ERROR unity expected. insert a semicolon at the end
everytime i get this error and really dont know how to fix it i tried many things but keeps coming up the scirpt is this
pragma strict
Var X : float;
function Start () { //Gathering normal object scale x X = Transform.localScale.X; }
function Update () { if(Input.GetKey("a")){ //Gamer pushes left a key //Set texture to normal position. transform.localScale.x = X; }else if(input.GetKey("d")){ //push d //Flip the texture transform.localScale.x = -X; }
}
Answer by jeffa070 · Apr 20, 2014 at 05:16 PM
okay i've fixt it i had Progma and it needed to be pragma
for posting solution. Tick your own answer correct to close this.
Answer by tw1st3d · Apr 20, 2014 at 01:13 AM
Looks like your issue was that you had Var
instead of var
, and Transform
instead of transform
. Also, I don't know if Input.GetKey
is a thing, so I've changed it to Input.GetKeyDown
. Lastly, transform.localScale.x = -X;
needs to be transform.localScale.x = -Math.abs(X);
This gets the absolute value of the number, then converts it to a negative number.
var X : float;
function Start () {
//Gathering normal object scale x
X = transform.localScale.X;
}
function Update () {
if(Input.GetKeyDown("a")){
//Gamer pushes left a key
//Set texture to normal position.
transform.localScale.x = X;
}else if(input.GetKeyDown("d")){
//push d
//Flip the texture
transform.localScale.x = -Math.abs(X);
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Errors with script using Javascript. 2 Answers
Script error help ? 1 Answer
please help NullReferenceException object 1 Answer
error cs0120 1 Answer