c# - Unity3d trigger event action to change a text in a canvas after another object passes through a trigger -
i'm having trouble script in unity
tried didn't work
public collider a; public text text; void update(){ if(a.collision.tag == "object") text.text = "trigger works"; }
then attached game elements public variables in editor.
first update
not monobehaviour function. update
.
secondly should watch this.
you need add collider
gameobject
set colliders is trigger
field true.
after need add ontriggerenter and/or ontriggerexit and/or ontriggerstay script.
for example:
//public collider a; public text text; void update(){ //dont need use update. } void ontriggerenter(collider other) { if(other.gameobject.tag == "object"){ //set text whatever want. } }
Comments
Post a Comment