Search Unity

Instantiating Particle Effects

Discussion in 'Scripting' started by Jackoh, Jul 17, 2019.

  1. Jackoh

    Jackoh

    Joined:
    Jun 27, 2019
    Posts:
    2
    Hi everybody, I am extremely new to this, and I have been trying to instantiate a smoke particle effect prefab when the character enters fire. The problem is that when i do so, the smoke doesn't go up anymore. It just circles around itself like a ball of smoke.


    public class fireFloor : MonoBehaviour
    {

    public ParticleSystem smokeEffect;

    }
    void OnTriggerEnter2D(Collider2D other)
    {
    playercontroller controller = other.GetComponent<playercontroller>();
    if (controller != null)
    {
    Instantiate(smokeEffect, transform.position, transform.rotation);
    }
    }
    }

    // If I just instantiate(smokeEffect)

    the smoke looks perfect, but it's not where it's supposed to be. Any attempts of changing its location, and I get the little ball of smoke not going up. I've tried creating a child game object and a public smokePlace to instantiate it there, but again, the same error.

    Any thoughts?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    6,011
    I don't see anything wrong here. In your particle system you need to use settings which give the particles speed and tell them to move in your desired direction. The problem could be there, or could be in some other script if you are moving or rotating the instantiated particle system object. For example, if you have the particle system set to send particles upward relative to its own local space, but you then rotate the particle system in a circular motion, it could appear as a ball (when the particle system is upside down, it still emits in its local upward direction, which would be downward, etc).
     
  3. Jackoh

    Jackoh

    Joined:
    Jun 27, 2019
    Posts:
    2
    Hey, thanks! I was going mad thinking my script was wrong. I actually solved the problem by adjusting the Force Over Lifetime Y value (it was 0). Now it works perfectly!
     
    Joe-Censored likes this.