Search Unity

C# bool not getting set to true...

Discussion in 'Scripting' started by vivek599, Oct 1, 2019.

  1. vivek599

    vivek599

    Joined:
    Sep 27, 2019
    Posts:
    25
    my bool is not getting set to true.... whats the issue...


    help...........

    code:

    if (choppingBoardSelectIndexP1 == 1 )
    {
    bTwoVegSelectedP1 = true;
    }

    bTwoVegSelectedP1 is false after this.....
     
  2. Antypodish likes this.
  3. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,465
    I agree with Ninja. Honestly, we just need more information as well. Are you ever setting that bool back to false or is it supposed to stay true once that choppingBoard variable is equal to 1?
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You should post the entire script, because the reason why it is false is most likely in the surrounding code.
     
  5. vivek599

    vivek599

    Joined:
    Sep 27, 2019
    Posts:
    25
    i logged choppingBoardSelectIndexP1 for values 0 to 8 or more... it is in input.getkeydown() function

    it is definately setting to 1 and bool was not setting to true..

    i resolved this issue by copy and pasting entire script in to a new script with new file and new name....

    ...
     
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    That wouldn't have fixed the logic. There was some other issue. Maybe you had multiple instances of the script in your scene when you didn't expect to for example.
     
    Yoreki likes this.