- Home /
GUItexture displayed after al triggers activated
Hello I would like to know how I would be able to activate a gui texture after all triggers are activated. Such as when the player activates three triggers I would like to display a gui texture, but only after all three of the triggers are activated. Thanks.
Answer by Ericool · Jan 10, 2015 at 01:27 AM
Trigger needs a collider with the property istrigger enable then implement a script attached to these gameobject with the method OnTriggerEnter(Collider col){your stuff; activated = true;} Which a boolean set to false inside the class and public as well. Then your player need the three gameobject script reference. And call this on the three ref:
Bool a = Gobj1. GetComponent(scriptname).activated; Bool b = Gobj2 GetComponent(scriptname).activated; Bool c = Gobj3. GetComponent(scriptname).activated;
If (a&&b&&c){ do something; Set activate vars to false if you intend to repeat this; }
Sorry if there is mistakes...
thanks so would you assemble the script somewhat like this? (sorry im new to unity and scripting) #pragma strict
var youwinGUI : GUITexture; var zombie : GameObject;
function OnTriggerEnter(Collider){zombie, activated = true;}
Bool : a = Gobj1. GetComponent(Trigger).activated;
Bool : b = Gobj2. GetComponent(Trigger).activated;
Bool : c = Gobj3. GetComponent(Trigger).activated;
If (a&&b&&c){activated; youwinGUI.enabled = true;}
im getting some errors on it tho