Particle effects

I want some particles to get activated when a bullet hits the enemy spaceship in my top down 2D game.
So i wrote a script where i use collision tags to check if its the bullet that has hit the enemy or not.

using UnityEngine;

public class EnemyAnimationScript : MonoBehaviour
    public ParticleSystem sparks1;
    bool isPlaying = true;

    private void OnCollisionEnter2D(Collision2D collision)
        if(collision.gameObject.tag == "Bullet" && isPlaying == false)
            isPlaying= false;

But this doesn’t seem to work.

  1. I created a prefab of the particle effect and added it as a child of my enemy. This makes the particle effect start as soon as the game starts

  1. I referenced the prefab using my script without keeping it in Hierarchy. This doesn’t even play the animation cause the game doesn’t know where to play the particles (1)

Please HELP!!

Btw those explosion effects work because they are game objects. But those sparks on the red spaceship don’t work :sneezing_face:

I have fixed this thanks!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms