- Home /
How do I properly use particle simulation in Unity?
So I'm using Unity's simulate function to pre-render particles. So that I can already have clouds moving over head, without the player having to wait.
It seems that simulate is not quite working as to what I expect. It's most likely a setting that I missed. But I just really cannot find the issue.
This is from inside the editor, I clicked on the particle object and just let it run. This is what I'd like.
This is after I've run the game a little bit, then hit pause. This is what is currently happening, for some reason the particles get bigger.
Here is the script that I've attached.
public float initTime;
public ParticleEmitter partEmitter;
// Use this for initialization
void Start () {
for (float i = 0.1f; i < initTime; i = i + 0.1f) {
partEmitter.Simulate(i);
}
}
As asked, here is also a what my Particle Renderer settings looks like.
Here are more of the settings, but fully expanded
I've run this scene in both Unity 3.5 and in Unity 4.0. Same thing happens in both versions.I'm pretty sure that it's something to do with the script. But I've tried many different pieces of code and they are all similar and do the same thing.
Just checking, what settings do you have on your particle renderer?
@Hyperion: I've added the screen shot. Do you have any thoughts on this?
Alright, your renderer settings are fine. Next, we must check the particle animator, and in fact, the emitter. Unfortunately I forget which of these has the settings for velocity and stuff like that. By the way, thanks for the picture.
Also, to make the growing less visible, it is possible to decrease the max lifetime (energy) of your particles. But that probably won't solve the problem. Could you please show me the other settings too?
Oh, and you said clouds. Since clouds are similar to fog, there is a camera script that allows you to prerender fog. I'm showing this just in case the script is the issue.
using UnityEngine; using System.Collections;
public class example : $$anonymous$$onoBehaviour {
private bool revertFogState = false;
void OnPreRender() { revertFogState = Render Settings.fog; RenderSettings.fog = enabled;
}
void OnPostRender() { RenderSettings.fog = revertFogState; }
}
Sorry for over commenting, but since you are using particleemitter.Simulate, there also might be a setting in the partEmitter regarding size over time.
Answer by Hyperion · Jan 24, 2013 at 09:18 PM
Okay, here's that answer posted. And I also had one other thing to say: Make sure your World Velocity is set to 0 in X,Y, and Z. That'll mean the clouds can't get stretchy.
Javascript/Unityscript:
var emitter: ParticleEmitter;
function Update () {
// Simulate 10 seconds
for (i = 0; i < 10; i++) {
emitter.Simulate(1.0);
}
}
I think C# would be:
ParticleEmitter emitter;
void Update () {
// Simulate 10 seconds
for (i = 0; i < 10; i++) {
emitter.Simulate(1.0);
}
}
Your answer
Follow this Question
Related Questions
Can you change the Velocity Over Lifetime of a Particle System using a Script? 3 Answers
C# Emit Particle Upon Left Mouse Click 2 Answers
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
A node in a childnode? 1 Answer