Insert a semicolon at the end error.

I tried to make a script but I got this error.

Assets/Move.js(8,17): UCE0001: ‘;’ expected. Insert a semicolon at the end.

How do i fix this error?
This is my script.

#pragma strict    
function Update () 
{
      var moveHorizontal = Input.GetAxis("Horizontal");
      var moveVertical = Input.GetAxis("Vertical");
}
{
      Vector3 move = new Vector3(moveHorizontal, 0 , moveVertical);
      rigidbody.AddForce(move);
}

1 Answer

1

You seem to have two blocks but one is outside the Update. Either it all goes in the Update or you need to create a method to use the second part but I doubt you are after that since you are using local variables in the second part.

function Update () 
{
      var moveHorizontal = Input.GetAxis("Horizontal");
      var moveVertical = Input.GetAxis("Vertical");
      var move:Vector3 = new Vector3(moveHorizontal, 0 , moveVertical);
      rigidbody.AddForce(move);
}

Still doesn't work.

What do you mean: -It doesn't work the way you expect? or -It throws the error still?

If you still get the semi colon error, you may want to copy paste the script on notepad, remove the script from Unity, create a new one and paste. Sometimes Unity goes childish. If the error is different you need to tell.

I don't work in javascript, but I don't think you need "new" in front of Vector3

Oh actually the Vector3 is wrongly declared!! The new is not necessary but can be placed.