- Home /
The question is answered, right answer was accepted
How to optimize if statements - can't remember term
I'm pretty sure there's a better way to write multiple condition if statements and thier result - but I can't remember the term/method so I can't find the scripting reference.
I want to optimize something that looks like this for example:
if(playerLocation == there){
moustache = long;
}
if(playerLocation == here){
moustache = short;
}
if(playerLocation == inATree){
moustache = GODLY;
}
if(playerLocation == inAHouse){
moustache = whatMoustache;
}
If anyone can point me in the right direction that would be moustache appreciated. I'm trying to optimize my code now :)
you're possibly thinking of switch, dude
it's almost certain that what you als need is inmuerators ... ENU$$anonymous$$
check it out !
Answer by FlintCLeaver · Sep 22, 2012 at 10:37 AM
Thank you very much Fattie. I have looked up the term and found this which is very useful for anyone wanting more info on Switches
http://answers.unity3d.com/questions/217024/please-explain-a-switch-statement.html
Follow this Question
Related Questions
random range/if conditions? 2 Answers
"tag" & "if condition with OnTriggerEnter 2 Answers
Wearied Error 1 Answer
Using a particle System in an if statement 1 Answer
nested if statements doubt 2 Answers