i need take value of boolean (put in variable called "bouclier") set in 1 script enable or disable gameobject.
the variable in game object player (bottom right here):
and need enable of disable game object ("bouclier01"):
to this, attached script game object "bouclier01". here is:
using unityengine; using system.collections; public class showbouclier : monobehaviour { public gameobject bouclier01; public bool bouclier; // use initialization void start () { bouclier01 = bouclier01.getcomponent<gameobject>(); } // update called once per frame void update () { bouclier01.enabled = false; if (bouclier == true) { bouclier01.enabled = true; } } }
i must missing something, because comes error message:
any idea how accomplish this?
use gameobject.setactive() function activating or deactivating gameobject this:
bouclier.setactive(false);
i think gameobject.enabled in old unity apis. if want know current activation state of gameobject use gameobject.activeself, read variable, this:
debug.log(bouclier.activeself);
Comments
Post a Comment