// If the prop is facing left, it should start on the right hand side, otherwise it should start on the left.
float posX = facingLeft ? rightSpawnPosX : leftSpawnPosX;
This is the code that is giving me issues. I apologize if this has been asked before; my attempts to google anything with “?” or “:” in it were not very fruitful.
Can someone explain this code to me? I think it’s something related to comparison statements, but I read it long ago and can no longer remember. Specifically, what are the functions of “?” and “:”?
If the condition is true, the first expression is evaluated and returned, otherwise the second expression is evaluated and returned.
So in your case, facingLeft must be a boolean variable (true or false). If you were to use a method instead of the conditional operator, it would look something like this:
Thank you!
– AxisRobNo problem :)
– hamstar