- Home /
Find object that enters trigger
I'm trying to find the object that enters a trigger so the trigger can be parented to the object that enters, but I'm not sure how to approach it. Does anyone have any suggestions?
               Comment
              
 
               
              Answer by m4s4m0r1 · Jul 17, 2013 at 01:26 AM
you can use OnTriggerEnter for this, Example:
 function OnTriggerEnter (obj : Collider)
 {
    if(obj.gameObject.tag == "Your Tag")
    {
      transform.parent = obj.gameObject.transform;
    }
 }
But is it possible to use something like gameObject.Find()? Because I want to be able to child this trigger to any object in the game
yup you can... you can use gameObject.Find() for this.
 transform.parent = gameObject.Find(//Name of gameObject).transform;
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                