- Home /
EOF error message
im new to unity and javvascript (i used to use as2 in flash) and when trying to loop a animation using this code:
function Update ()
{
if (Input.GetAxis("Vertical") > 0.2);
var rhs=true;
}
else{rhs=false};
while(rhs=true);
{
animation.CrossFade ("right hand swing");
if (Input.GetAxis("Vertical") > 0.2);
var rhs=true;
}
else{rhs=false};
}
}
it gave me the error message (6,4) expecting EOF, found else
how can i fix this
EOF stands for End of File which is a common error if you've forgotten to curly brace a block of code. However your syntax is not quite there yet, check the answer below.
Answer by save · Jun 01, 2011 at 08:43 AM
Your syntax is a bit messy, try approaching with this instead:
private var rhs : boolean = false;
function Update () {
if (Input.GetAxis("Vertical") > 0.2) {
animation.CrossFade ("right hand swing");
rhs=true;
}else{
rhs=false;
}
}
Answer by CHPedersen · Jun 01, 2011 at 08:44 AM
The curly brackets in your code are positioned totally whack. You seem to have misunderstood how they're used. A set of curly brackets tie the contained block of code to the statement located just before the beginning bracket. I.e. you have a function, Update, that does this:
function Update ()
{
if (Input.GetAxis("Vertical") > 0.2);
var rhs=true;
}
And that's it. The compiler thinks the if-statement is all you want to do in Update, because that's all you've but in between the two curly-brackets that belong to Update.
This is how to construct conditionals inside Update:
void Update()
{ // Update's beginning bracket
if (something)
{
// Is executed if something is true
}
else if(something else)
{
// Is executed if something else is true
}
else if(something third)
{
// Is executed if something third is true
}
while(something fourth)
{
// Is executed while something forth is true
}
} // Update's ending bracket
As a finishing note, remember that single equals '=' means assignment, and double-equals '==' means comparison. while(something = true) doesn't make any sense, and will produce compiler errors, because the expression assigns true to something, it doesn't test if something is true.
Your answer
Follow this Question
Related Questions
sript gets error 2 Answers
BCE0044: expecting }, found 'class' alond with BCE0044: expecting EOF, found 'Card' 1 Answer
An EOF Problem :( 1 Answer
An EOF Problem :( (New) 3 Answers
script error GUI super simple code 3 Answers