Search code examples
c#unity-game-engineparticle-system

ParticleSystem issue with enableEmission


that's my very first question in here (not a first visit searching solution, though ;D).

I've got an issue with ParticleSystem in Unity:

    if (!dead) {
        dieBang.enableEmission = false;
        Vector2 newVelocity = rigidbody2D.velocity;
        newVelocity.x = forwardMovementSpeed;
        rigidbody2D.velocity = newVelocity;
    } else
        dieBang.enableEmission = true;
    UpdateGroundedStatus ();

The problem is dieBang.enableEmmision gets true only when dead state is caused by on object(laser) I manually "put" in the game. When character hits laser generated of prefab, it gets dead, stop moving etc. , but there is no dieBang :D Hope you can help me


Solution

  • It's hard to say with the limited info here but I have a hunch that your particle system is being destroyed with the character so you will never see the particle effect.

    Either destroy the character after the effect is complete or instantiate the particle system without a parent so it isn't destroyed by accident.

    EDIT: Also worth noting, if you're simply disabling the character when it's hit instead of destroying the game object, you'll have the same effect because the parent is disabled, thus disabling the children(ie. the particle system).