- Home /
Weird behaiviour with particle system.
I have a very simple script that when "isMoving" is checked should;
start moving the object left
play the particle system
however, lol...what is happening instead baffles me.
The object will move but the particle system does not play until...
I unchecked "isMoving". At that point, the object obviously stops moving and then the particle system kicks in! It's completely backwards!
#pragma strict
var speed: float = 05;
var myEffect: ParticleSystem;
var isMoving: boolean = false;
function Start ()
{
myEffect.Stop ();
}
function Update ()
{
if (isMoving)
{
Rolling ();
}
}
function Rolling ()
{
myEffect.Play ();
transform.Translate(Vector3.left * Time.deltaTime * speed );
yield;
}
Answer by Simon-Larsen · Apr 10, 2014 at 01:52 PM
What's going on here is that you are continuously calling the particle system to start itself. But as you do this you also reset the particle system, so you are practically constantly resetting it which results in no visualization.
What you can do about this is check if your particle system is already playing before you ask it to play, like so:
if (!myEffect.isPlaying)
myEffect.Play ();
Your answer
![](https://koobas.hobune.stream/wayback/20220613142413im_/https://answers.unity.com/themes/thub/images/avi.jpg)