Search Unity

Particle system does not play when calling method .Play()

Discussion in 'Scripting' started by bernardp, Jun 17, 2019.

  1. bernardp

    bernardp

    Joined:
    Apr 28, 2017
    Posts:
    23
    I created a simple particle system that is inside a prefab:

    upload_2019-6-17_23-3-14.png

    The particle system dos not play on Awake and it plays normally in scene editor.

    In prefab script I set a reference to the particle system:

    Code (CSharp):
    1. public ParticleSystem psEffect;
    2.  
    I dragged the particle system game object to the game object slot in script component and when the player collides with the object, I call this line in OnCollisionEnter2D():

    Code (CSharp):
    1. psEffect.Play();
    However, the particle system is never playing ingame! I called Debug.Log(ps.isPlaying). Before the particles are played, it writes 'false' to log and writes 'true' after calling .Play() function.

    What am I doing wrong?
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    How do you know it's not playing? Are you using an runtime console to view if it is once on the device?

    It's possible it's a layering issue that you're just not seeing once on the device and it's playing behind the scene or gui.
     
  3. bernardp

    bernardp

    Joined:
    Apr 28, 2017
    Posts:
    23
    I test it out by calling .Play() in game object Start() function and the particle system played. But calling the .Play() in collision check doesn't play it.
     
  4. veonalmeida2003

    veonalmeida2003

    Joined:
    Apr 20, 2022
    Posts:
    1
    Facing the same bro any solutions plss!!??