Scripting particle systems.

So, i have been looking into this for some hours now, but i really cant find a solution, or tips on how to do this.

There are two issues, one being: Is it possible to make a script for a particle emitter, ie, controlling the force on an axis with a random number script. And the other being: Is it possible to use a mesh instead of a texture on the particle emitters.

I know it is possible to script the particle emitters, what i dont know though, is how to do it, so if anyone has some reference to some tutorial or whatever, it would be very welcome.

I'm kinda new to scripting and unity, so if there's some parts that doesnt make sense in this text, that is probably the reason.

-Seth

The docs describe how to script particles: http://unity3d.com/support/documentation/ScriptReference/ParticleEmitter-particles.html. You can't use meshes for emitted particles.

The closest thing you can do to emitting meshes is a mesh spawning object. Simply create an empty object and add this script, then drag the desired prefab to the variable slot in the inspector. Set the interval to the desired value and play. (Smaller interval value = faster emission rate.)

var prefab : Transform;
private var randomNumX : float;
private var randomNumY : float;
private var randomNumZ : float;
var interval : float;
private var nextEmit : float;

    function Start(){
    nextEmit = interval;	
}
    
    function FixedUpdate(){

      randomNumX = Random.Range(-400,400);
      randomNumY = Random.Range(-400,400);
      randomNumZ = Random.Range(-400,400);

      if (Time.timeSinceLevelLoad > nextEmit){
      	 
     nextEmit += interval;
      MakeObject();
      }
}
    
    function MakeObject(){
    
    madeOb = Instantiate(prefab, transform.position, transform.rotation);

       if(madeOb.rigidbody){
     madeOb.rigidbody.AddForce(Vector3(randomNumX,randomNumY,randomNumZ));
    }
}