Starting state for a particle system

I have a small learning project that I'm doing. It works nearly flawlessly in the game mechanics, and I'll probably post it once I polish it up. One of those polishing points is that I've used a particle system for a quick-and-easy starfield. The starfield looks great, except for one thing: it takes about ten seconds for the particle system to get started, before which the background is just black. Then the stars start to filter down and it finally looks like stars going by.

In Maya, there is an option for a physics simulation to save the initial state. In this case, I would run the simulation for about ten seconds, and then stop it and save the initial state. Then, whenever I start it normally, it starts where it left off (where I saved the initial state).

Is there a fairly simple way to accomplish this in Unity?

Just use the Simulate method of the ParticleEmitter.

Something like this should work:

var initialTime : float = 10.0;

function Start() {
particleEmitter.Simulate(initialTime);
}

Works! It seems to work a little quirky in mono, however. I had to reference it through a public variable in order to get it to work:

public class PSStarter : MonoBehaviour {

    public float initTime;
    public ParticleEmitter PE;

    void Start () {
    	PE.Simulate(initTime);
    }

}

I guess it's better to do it that way anyway, so I can adjust the skip-forward time without opening the script. Thanks for the tip!

ParticleSystems have the Prewarm attribute that can be selected via the Inspector. This will start the particle system as if it had gone through one cycle already (will only work if the system is also looping.)

28565-capture.png

Just to clear things up:

The first example is in JavaScript, and the second in CSharp.

This is the correct link to Simulate

I discov-invented a cheap trick for making seemingly very efficient starfields... all you need to do is find a decent starfield texture (white dots on black background) and create a cube that spans your game area, with the front and back faces of the cube set to be however far apart you want your two planes of stars to be. Set the texture to "iphone->particles->Additive" and tile it appropriately, say 40x40 and wa-la you have two planes of stars for 1 draw call, 1 object. Duplicate the object, offset the y axis and rotate around the y for an additional 2 planes of stars. If you have maya or 3ds, you could even create a single mesh of multiple planes for similar speedy goodness.