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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -