How can I write "or" in c# script

Hello sir, I’m a newbie and sorry if this is a stupid question.

if (other.gameObject.tag != ("StealthKillA") ("StealthKillB")("StealthKillC")("StealthKillD")) return;

This code is error no doubt, as you can see I got 4 tags with a similar idea and I try to write it into c# script. How do I tell in c# that “if tag not equal to StealthKillA or StealthKillB or StealthKillC or StealthKillD” … return;

For now, I solve this by writing the hold thing again 4 times (Stupid I know) but how to write it correctly?

Or better yet: http://learncs.org/

2 Likes

You actually probably want ‘and’ for this one, not or. Boolean logic doesn’t quite work the same way as spoken logic.

if (other.gameObject.tag != ("StealthKillA")
    && other.gameObject.tag != ("StealthKillB")
    && other.gameObject.tag != ("StealthKillC")
    && other.gameObject.tag != ("StealthKillD")) return;
1 Like

Thank you, sir. This helped me a lot.