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

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 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;
	}
}