Search Unity

problem to visualize a Particle System

Discussion in 'Editor & General Support' started by josiperez, Dec 13, 2017.

  1. josiperez

    josiperez

    Joined:
    Jan 12, 2017
    Posts:
    32
    Hi
    I tested 5 different Particle System in a separate project; I hidden 4 and tested 1, until have each one in a relative good way. Now I put this separate project inside my game, as a new scene, including the 5 Particles.

    The goal: at each end of a game level I would like to call one Particle System, under a background in solid color; when the player press any key the game returns to the normal way.

    The problem: I can not do this.
    What I tried without success:
    a) to call each Particle System using Play(): I lost the solid background

    b) to include each Particle System as gameObject under the changeLevel scene: I can't see the effect for error:
    There is no 'ParticleSystem' attached to the "GameFlowManager" game object, but a script is trying to access it.
    Tried:
    stars.GetComponent<ParticleSystem>().Play();
    stars.Play();
    stars.Emit(10);


    c) to create one different scene for each Particle System: the better result, but I can't stop the effect and come back to the game.

    Can someone give me directions or sugestions to got it.
    Unity 3D 5.6.4f1 windows 10

    Thanks in advance,
    Josi
     
    Last edited: Dec 13, 2017
  2. josiperez

    josiperez

    Joined:
    Jan 12, 2017
    Posts:
    32
    Please, help... not success yet trying to call different particle system effects at the level end.
    1) made 2 Particle System in a separate project: star and firework
    2) in a game where I need to show the Particle System:
    a) copyed star and firework under a canvas (background dark blue) under a Scene where the effects are needed
    b) on the script:
    i) declare:
    public ParticleSystem stars;
    public ParticleSystem fireworks;
    and in Inspector made the association to these variables

    if I declare as gameObject considering ParticleSystem is obsolet, I do not have stars.particleSystem (it is strikethrough)
    ii) define on Start ():
    stars = GetComponent<ParticleSystem>();
    fireworks = GetComponent<ParticleSystem>();​
    iii) activate the canvas and one particle System:
    screenFireworks.SetActive(true);
    stars.Play ();​
    I'm getting the error:
    MissingComponentException: There is no 'ParticleSystem' attached to the "script" game object, but a script is trying to access it. You probably need to add a ParticleSystem to the game object "script".

    If someone can indicate a link with conceptual explanation about this I appreciate.
    Thanks in advance.
     
    Last edited: Dec 20, 2017
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    I guess, you access a ParticleSystem, that you retrieved via GetComponent(), that points to null. In this case, Unity outputs that error message as far as I remember.

    To narrow down the issue, you could add some "if (screenFireworks == null) Debug.Log" after the GetComponent<ParticleSystem>() call that gets the screenFireworks ParticleSystem for example.

    If you know how to use the Visual Studio Debugger, you could add conditional breakpoints instead. This should provide some insight when a ParticleSystem is null and you have some context, such as on which object it's missing.
     
    josiperez likes this.
  4. josiperez

    josiperez

    Joined:
    Jan 12, 2017
    Posts:
    32
    Thank you very much Peter.
    I use monoDevelop debug attached to Unity, but for me, it was so clear that the correspondence was made :( It is really null.

    I tried the syntax described here:
    1. public GameObject dustPuff;
    2. private ParticleSystem dustParticle;

    3. void WhateverFunction () {
      1. GameObject dustObject = Instantiate(dustPuff, this.transform.position, this.transform.rotation) as GameObject;
      2. dustParticle = dustObject.GetComponent<ParticleSystem>();
    4. }
    and now, it is not null, but I'am not getting the effect working, using the syntax described in the same link:
    1. var dustPrtcl = dustParticle.emission;
    2. dustPrtcl.enabled = true;

    Suggestions about what i'm doing wrong?
    I'm trying to activate the particle in a panel without character, just enable the firework - is it wrong?
     
    Last edited: Jan 10, 2018