- Home /
Particles stop emitting?!
The particle emitter stops emitting after i use the slider to change the direction of particles to the right?! It moves some of the particles but then stops emitting all together? Why is this happening? Im i missing something? Plz help!
var speed: int=5; var right : Vector3; static var Slide: float =0;
function Update (){ transform.Translate(Vector3.right * Time.deltaTime*Slide);
}
function OnGUI(){ GUI.Box (Rect(5,150,90,55), "Wind Direction"); Slide = GUI.HorizontalSlider (Rect(10,155,80,30), Slide, -200,200); }
Not enough info here. What particles? Is this attached to an object with a particle emitter on it? What is Slide used for?
I have just a simple particle emitter that this code is attached to with a slider called Slide. I just need the Slider to change the direction of the particles being emitted. It does this but only for a second and no more particles are emitted after the slider has been moved and your left with an empty scene?
Answer by Alec-Slayden · Feb 25, 2011 at 07:32 PM
Your code will not change the particle direction, it will move your whole emitter.
Your particle emitter is on a game object, and it is the transform of that game object that you're translating to the right with
transform.Translate(Vector3.right * Time.deltaTime*Slide);
Since you're doing that every frame, it will quickly race out of camera view. It could seem as though the particles are moving to the right, but really the whole system is.
what you'll want to do is modify the localVelocity or worldVelocity of the particles being emitted to adjust their starting direction. if you want all of them to immediately change direction you'll also want to look into particle velocity, which is slightly trickier since you have to go through the particles.
if the script is on your emitter you can access the local or world velocity Vector3's like so:
transform.particleEmitter.localVelocity
Your answer
Follow this Question
Related Questions
Activating a particle emitter whith onTriggerEnter ? 5 Answers
Particle delay 1 Answer
Particle Emitter Breaks in emission. Help? 1 Answer
Particles do not appear on play but do on emit 0 Answers
Particle Sub Emitter Bug 5.5.3f1 0 Answers