Printing Collided Object

Hi,

is there a way I can tell the name of an object that collides with my trigger object? Like “‘Ball x’ touched the trigger!” - couldn’t find any documentation on it, but then again, I might have just been looking in all the wrong places :frowning:

Something like -

function OnTriggerEnter (other : Collider) {  
Debug.Log ("Name of Object here" has hit the trigger);

}

1 Answer

1

Hi again,

function OnTriggerEnter (other : Collider) {  
      Debug.Log (other.gameObject.tag);    
}

or

function OnTriggerEnter (other : Collider) {  
          Debug.Log (other.gameObject.name);    
    }

depending on what you want.

fafase - I think I love you a little. Thanks, again <3

You should also mark the question as answered. You can also give a thumb up to show that the answer is right. That helps for future consultations, people know right away that the answer is right.

Show your love through the big ol' tick!

You don't have permission to do this action. Please Login as another user - on the thumbs up :(

yep I have had the same problem before... dunno why but you cannot thumb up a post on your own thread...