- Home /
 
               Question by 
               dudedude123 · Feb 26, 2014 at 08:41 PM · 
                collisiongameobjectparticle  
              
 
              Particle colision using shruiken
I'm using the shruiken particle system and made code for it
 using UnityEngine;
 using System.Collections;
 
 public class Fire : MonoBehaviour {
 
     
     public GameObject water;
 
     private bool destroyed = false;
 
 
     // Use this for initialization
     void Start () {
 
     }
     
     // Update is called once per frame
     void Update(Collision collision)
     {
         
 
         if(collision.water.tag)
             Destroy(gameObject);
         
 
     }
 
 }
How do I get it to disappear after colliding with anher game object?
               Comment
              
 
               
              Answer by Dblfstr · Feb 26, 2014 at 09:02 PM
You need to use either:
 OnCollisionEnter(Collision col){}
or
  OnTriggerEnter(Collider col){}
Not update Then you check the tag of the collider
 if(col.gameobject.tag == "water")
 {
    Destroy(this.gameobject);
 }
Assuming your water is tagged "water". And this is attached to you fire particle system.
so:
 using UnityEngine;
 using System.Collections;
  
 public class Fire : MonoBehaviour {
      
 OnCollisionEnter(Colliision col)
 {
     if(col.gameobject.tag == "water")
     {
         Destroy(this.gameobject);
     }
 }
}
Is your water tagged "water" maybe its Destroy(this.gameobject);
I wrote this off the top of my head, so I didn't get to test it.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                