Question by
Blackrobot · Jul 28, 2013 at 01:45 PM ·
c#gameobjecttrigger
How can i get the name of the gameobject that triggered a trigger?
Hello, I made a simple Waypoint System, where my AI runs in a circle of waypoints ([Picture][1]). The waypoints are the Trigger and they have the OnTriggerEnter on them. My Problem is I want to know which gameobject triggered the trigger but when i write Debug.Log(gameobject.name); I get only the name of the waypoint. How can i get the name of the AI that triggered the trigger?
Sorry for my bad English :) [1]: http://www.bilder-hochladen.net/files/big/e7pl-5r-854d.jpg
Comment
Best Answer
Answer by dorpeleg · Jul 28, 2013 at 01:48 PM
You need to check for the name of the collider, not the name of the object.
See this: Collider.OnTriggerEnter.
All you need to change in that code, is this line:
Destroy(other.gameObject);
to:
AIname = other.gameObject.name;
:)