c# - boolean not updating with code in Unity -


i have script changes score randomly. , b. want scores change button type false true depending on condition. reason won't change.

unless scores even, last script should continually change true or false. want these last until next button pushed.

i have printed out information, know scores being pulled in don't seem calculating.

public static bool yaybutton = false; public static bool boobutton = false;  scoremanager.scoredisplaya; scoremanager.scoredisplayb;  if(scoremanager.scoredisplaya > scoremanager.scoredisplayb){         yaybutton = true; } if(scoremanager.scoredisplayb > scoremanager.scoredisplaya){         yaybutton = true; } 

you set yaybutton true in both condition, first mistake.

with code once 1 of variable become true, true think need turn other variable false.

and code must in update() or fixedupdate() method detect new change of scoremanager.

your final code should this:

public static bool yaybutton = false; public static bool boobutton = false;  scoremanager.scoredisplaya; scoremanager.scoredisplayb;  void start() {     // define scoremanager.scoredisplaya , b here.     // this:     // scoremanager.scoredisplaya = gameobject.find("scoremanager").getcomponent<scoredisplaya>(); }  void update() {     if(scoremanager.scoredisplaya > scoremanager.scoredisplayb){         yaybutton = true;         boobutton = false;     }     if(scoremanager.scoredisplayb > scoremanager.scoredisplaya){         yaybutton = false;         boobutton = true;     } } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -