- Home /
Noobish Question Pertaining to JS Movement
Okay, I was messing around with unity, and I'm trying to figure out how to make movements, but when I use this code it says that on 6,66 I need a semicolon, but I already have one there. Advise.
function Update ()
{
if(Input.GetButtonDown(KeyCode.ForwardW))
{
transform.position.z += .25;
setTimeout(function (){transform.position.y += .1}, 0050);
}
}
Answer by Eric5h5 · Nov 03, 2012 at 10:15 PM
The "setTimeout" line doesn't use valid syntax; not sure what you're trying to do there. Also, GetButtonDown takes a string, not a KeyCode (and there is no KeyCode.ForwardW enum). I would encourage you to put "#pragma strict" at the top of your scripts so errors like that will be caught at compile-time instead of run-time.
Answer by Streamline Games · Nov 04, 2012 at 04:10 PM
I think it's reading the curly braces. JS doesn't use curly braces in the middle of a line, they are used for delaring a Body of code. Replace them with normal brackets and remove the ones befor the curly braces, then it should work.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
A node in a childnode? 1 Answer
Preventing Rapid Fire 2 Answers
Make GUI.TextArea show up only when Left Ctrl pressed 1 Answer
Change int value for 30 sec... 1 Answer