i like to use ? : in a alot of my update functions just wondering if there is a difference in speed vs if else
I don’t believe so. The compiler condenses it down pretty much the same either way. Just write it whichever way feels most natural to you.
var x = 0;
if (Random.value < .5) {
x = 1;
}
else {
x = 2;
}
is slightly slower than
var x = Random.value < .5? 1 : 2;
However, the difference is small enough (a couple %) that you’d only ever consider it a factor if it was looping millions of times in a tight loop, and maybe not even then. So basically what FizixMan said…code readability is more important.
–Eric