Search Unity

If else problem

Discussion in 'Scripting' started by NotMyUsernameAgain, Jun 25, 2019.

  1. NotMyUsernameAgain

    NotMyUsernameAgain

    Joined:
    Sep 28, 2017
    Posts:
    139
    Hi everyone,
    it is 1:00 AM in the morning and my brain is not working that well anymore.

    So, I have the following code:
    Code (CSharp):
    1.  
    2. if(missedAttack) {
    3.             //do nothing
    4.         }else if(greenNumbers) {
    5.             //do nothing
    6.         }else {
    7.             //DO SOMETHING!!
    8.         }
    However I want to write it in a single "if() { }" code.
    I tried a bit with && and || and even with | operators, but I just can't figure out (right now) which correct conditional combination I should use, so that it becomes a simple if case.
     
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    Code (CSharp):
    1. if (!missedAttack && !greenNumbers)
    2. {
    3.     // Do something
    4. }
     
  3. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    This seems like a warning sign that you should be sleeping instead of coding.

    People who are sleep-deprived, like people who are drunk, tend to severely underestimate how impaired they are. Your efficiency will drop pretty rapidly if you do not sleep when you need to. It is possible for your efficiency to drop so low that you are actually making negative progress (when you make so many mistakes that debugging them will take longer than the original work should have taken).

    Pros sleep.
     
    DaemonicDreams likes this.