- Home /
BCE0044 Error in the Start function
This is my first time posting a question, so forgive me if I place the code wrong or something. Now, my problem appears to be with the curly brackets. I have looked at numerous answers and forums, but no luck. I have tried many variations with my script, and it just wont work.
This is what the Console states " (15,9) BCE0044: expecting }, found 'else'" and "(20,1): BCE0044: expecting EOF, found '}'."
I'm sure you guys can figure this out easy! Thankyou for your help!
function Start ()
{
//Check for right.
if (dirStart >= 5)
rightEnabled == true;
leftEnabled == false;
Right();
//Check for left.
else
if (dirStart < 5)
rightEnabled==false;
leftEnabled ==true;
Left();
}
Answer by fafase · Aug 07, 2012 at 09:12 PM
Hey,
You must be starting programming :)
function Start ()
{
//Check for right.
if (dirStart >= 5){
rightEnabled = true;
leftEnabled = false;
Right();
}
//Check for left.
else if (dirStart < 5){
rightEnabled=false;
leftEnabled =true;
Left();
}
}
Thanks for responding so fast, buuuuut I did this before and I got this "BCE0034: Expressions in statements must only be executed for their side-effects." Any ideas? Would you like to see the whole script?
Oh yes, you are comparing and not assigning in the conditions. That is what Unity is telling you. It tells you that in a condition (if statement), you need to perform an action that is changing something (side-effect). rightEnabled == true is comparing and not modifying anything.
Now what is your purpose, two possibilties,
you want to check if dirStart is greater than 5 AND rightEnabled is true AND leftEnabled is false, then you call Right()
you want to check only if dirStart is greater than 5, then rightEnabled is made true and leftEnabled is made false and also the function Right() is called
Depending what you want to do I will change the answer.
$$anonymous$$y purpose is the second option that you provided. Thanks again!
Done. = assigns the right value to the left value. == compare the left value with the right value and returns true or false.
I unfortunately cannot assume the position of a personal mentor. Furthermore, you can get dozens of mentors on this forum 24/7, and some of them are way better than me. Glad it helped though.
Your answer
Follow this Question
Related Questions
Else and If 2 Answers
An EOF Problem :( 1 Answer
Help playing the right animation 1 Answer
Why am i getting this error?! 2 Answers
How to finish my else if statement? 2 Answers