Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[solved] ParticleSystem of childobject starts but should not

Discussion in 'Scripting' started by Achim, Nov 22, 2018.

  1. Achim

    Achim

    Joined:
    Dec 19, 2007
    Posts:
    199
    Hallo,
    I have an object with a childobject, and both, the parent and the child, have a ParticleSystem.
    I start the ParticleSystem of the parent with this code.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class GischtStart : MonoBehaviour
    6. {
    7.  
    8.     void Update()
    9.     {
    10.  
    11.         if (Input.GetMouseButtonDown(1))
    12.         {
    13.  
    14.             var p = this.GetComponent<ParticleSystem>();
    15.             p.Play();
    16.  
    17.         }    
    18.  
    19.     }
    20. }
    21.  
    22.  
    But it starts both ParticleSystems (from parent and child object).
    How can I start only the ParticleSystem of the parent ?
     
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    5,457
    Put one of them next to the other. In other words: arrange on a way when they aren't in parent-child relationship.
    Code (CSharp):
    1. - root
    2.     - particlesystem1
    3.     - particlesystem2
    4. or
    5. - root
    6.     - particlesystem1
    7.     - child
    8.          - particlesystem2
    I have no better workaround.
     
    Achim likes this.
  3. Achim

    Achim

    Joined:
    Dec 19, 2007
    Posts:
    199
    I first had it arranged like this, what didnt work (thats why I opened the thread) :
    Code (CSharp):
    1. - root
    2.     - particlesystem1
    3.     - child
    4.          - particlesystem2
    now I made an empty object and made them both a child of it:
    Code (CSharp):
    1. - empty
    2.      -child
    3.          - particlesystem1
    4.     - child
    5.          - particlesystem2
    but both didnt work.
     
  4. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    5,457
    I tried in 2018.3b9 both of the hierarchy I had offered works for me. I was playing with your problem for a good half an hour. :)

    Maybe you should open a bug report about it with minimum viable project.
     
    Achim likes this.
  5. Achim

    Achim

    Joined:
    Dec 19, 2007
    Posts:
    199
    I think I know what I did wrong. I used the ParticlesSystem as a component (add component) and not the gameobject from effects dropdown list, which can be arranged as itself. Didnt think of the two possibilities.
    Think thats the solution.
     
  6. Achim

    Achim

    Joined:
    Dec 19, 2007
    Posts:
    199
    yes this was the problem, your hint with the hierarchy was right.
    Thanks :)
     
    Lurking-Ninja likes this.
unityunity