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?

1 Answer

1

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);
    }

}

}

I tried it and it don't work.

–

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.

–

That don't work either

–

Is it even detecting a collison?

–

Not really

–