Simple and looks interesting...

I saw this code:

 animation["Run"].speed = (Input.GetAxis("Vertical") < -0.2) ? -1 : 1;

I’m interested on what it means. Specifically: (Input.GetAxis(“Vertical”) < -0.2) ? -1 : 1;

What does this mean in layman’s terms?

I know it’s to set the Run animation speed from the Vertical Input… but the equation is what I don’t get.

I’ve very interested. Can someone shed some light to this? Thank you!

It is the same as saying this:

if(Input.GetAxis("Vertical") < -0.2) {
    animation["Run"].speed = -1;
}
else {
    animation["Run"].speed - 1;
}

You can read about it @ http://msdn.microsoft.com/en-us/library/ty67wk28(v=vs.80).aspx

I absolutely LOVE that statement…

Oooooooohhhhhh wow! Thanks! I’ll have tons of use for this!!! Absolutely a useful shorthand!
Thank you so much again!

Very cool.

If anyone’s interested, it’s called a “ternary statement” or “ternary operation”. Very useful and surprisingly self-documenting, even though it’s a one-liner.