Start a specific particles with a script

Hello,
I a little issue about particles.
I have a Bullet in a weapon and when I click, my weapon shoot my bullet and some particles are played (there are played automatically when the bullet is instantiate). But when the bullet hit something, I destroy it but I also want to start particles. The problem is that I have 2 particles in my bullet and I can’t Get any of them (and so start them).

So my question is, how can I start my particles in a script during the “destroying-of-my-bullet”. ?

Assuming:

  1. the particles are part of the bullet
  2. the bullet is destroyed on impact

Then the particles will be destroyed at the same time the bullet is.

To fix this:

  1. make the particles a separate prefab, OR
  2. detach the particles from the bullet by making it a child of the bullet, and then setting its parent to null.

Simple solution:

Instantiate particle prefab and set the transfrom position to the bullet hit point (position), then play & destory it after playtime.

void OnHit()
{
   Gameobject particle = GameObject.Instantiate(ParticleObj,Vector.zero.Quaternion.identity) as GameoObject;

particle.transform.position = bullet.transform.position;
particle.GetComponent<ParticleSystem>().Play();

}

Ok I will try to separate prefab :slight_smile: thx.

Nice thk, I will try it tonight :slight_smile: