Question by
ArmswieldTheHero · Oct 22, 2016 at 07:57 PM ·
if-statementsifif statement
How to use or statements in an if statement.
How would i say
if (myplayerlocation == predefinedlocation.transform.position or predefinedlocation2.transform.position or predefinedlocation3)
{
//do something
{
Comment
Best Answer
Answer by doublemax · Oct 22, 2016 at 08:07 PM
"||" is the operand for a logical "or". But you must use three separate comparisons:
if (myplayerlocation == predefinedlocation.transform.position ||
myplayerlocation == predefinedlocation2.transform.position ||
myplayerlocation == predefinedlocation3.transform.position )
{
//do something
{
Thank you, I knew about || but I didnt know why it wasnt working, you fixed my problem.
Your answer
Follow this Question
Related Questions
Unity Update is ignoring the GetKey part of my statement!? 2 Answers
Add changeable conditions in the editor, similar to unityEvent? 0 Answers
SqrMagnitude intermittently doesn't work for if statement on prefab. (C sharp) 1 Answer
If statement for direction the character is facing 0 Answers
The If statement condition is false but the if statement stills executes 1 Answer