Instantiate fire particle on a terrain (random if possible)

Hi,
I am new to this community! I downloaded Unity 2.6 since it has been free and I am making a game on firefighters. :slight_smile:

I have the following code to instantiate fire particles on a terrain:

var firePrefab : Transform;
function Start () {
	for (var z = 0; z < 2000; z+=100) {
		for (var x = 0; x < 2000; x+=100) {
			var firePrefab = Instantiate(firePrefab, Vector3 (x, 0, z), Quaternion.identity);
		}
	}
}
function Update () {
}

it works but it places all particles at y=0. What I want is that it detects the terrain altitude and then “drops” the particles on it… Is this possible?

P.S. is it possible to make a randm instantiation instead of placing them on a grid?

Thanks in advance!

Have a look at the MeshParticleEmitter class. Even if you want to instantiate a GameObject rather than a particle, you could use the position of an emitted particle to locate the object.

I tried with the Mesh Particle Emitter but I can’t select my particle system from the dropmenu!!!

Did you have an object selected at the time? Particle emitters are components that you must add to existing objects - they can’t be used in isolation.

I think you have misunderstood… :slight_smile:
I can’t select my particle system from the Mesh drop menu after I have added the Mesh Particle Emitter!

Or I am doing something wrong?