- Home /
 
               Question by 
               Mudu_ · Nov 23, 2019 at 03:20 PM · 
                c#collisiongameobjectinstantiatecollider  
              
 
              How can I check if an instantiated object collides with another instantiated object?
In my script I instantiate a game object (player) ,and another one (coin) ,and I want to see if that game object collides with that coin but i don't know how to do that.
               Comment
              
 
               
              Answer by HenriMR · Nov 23, 2019 at 04:49 PM
Firstly, both game objects MUST have a Collider or Collider2D. Then, one of them must have a script with the method OnCollisionEnter or OnCollisionEnter2D, in this method you can write what you want to happen.
If you do not want then to actually collide, you can check "Is Trigger" on the Collider Component and use the method OnTriggerEnter.
Hope it helps
Just to make sure, in case this is a 3d game, the process is the same for 3d, but remove "2D" from the name of every component.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                