[Solved] On showing particle syetem blowing up when enemy hit

I create a particle system called it Flame;
I then drop it into Enemy Folder;
I went to the EnemyBehaviour script and added a public ParticleSystem flame. Then I could drop the Flame object onto Enemy. At the bottom of the script where the ship is destroyed, I called flame.Play();

I hope all this make some kind of sense. Any suggestions would be appreciated.

Thanks Ray.

Hi @Ray_Beattie,

The only bit missing from your post really is the problem! :slight_smile: So, what is happening, or isn’t happening that shouldn’t / should be?

Sorry about that. No matter what I have tried to do when the enemy ship is destroyed I do not see the flame or explosion.

Does anything else happen at the same time which may cause it to not appear / disappear very quickly, for example, do you Destroy() the player’s ship, thus taking the flame ParticleSystem with it?

In the BlockBreaker game, from memory, I believe the SmokePuff particle was created as a prefab, this was then instantiated in code upon the relevant event.

1 Like

thats what it sounds like, as if a gameobject is destroyed at the end of a frame it effectively destroys all its children with it.

but, instantiating a prefab at that point of destruction (position and when it is destroyed), is effectively a separate entity in the scene, thus persists when the enemy that called it is destroyed.

you would then have a script attached to that prefab that was just created that would call a Destroy after a certain amount of time (time it takes for the explosion)

like Rob was saying, pretty sure that mechanic was added to the blockbreaker.

1 Like

Thanks To Both OboShape and Rob I was able to solve my problems. Here is what I did:

void Die()
AudioSource.PlayClipAtPoint(deathSound, transform.position);
// add this line and it solve it. Now it looks cool.
Instantiate(flame, transform.position, Quaternion.identity);


Nice one Ray, glad you got it working.

1 Like

Privacy & Terms