I am making an fps with some friends, and the first scene is a forest. I would like to have the ability to set the forest on fire, similar to far-cry 2. More specifically, I want a single fire particle system to spread out, maybe by spawning clones next to it, then eventually die.
I have no idea where to start with this. I have the particle system set up, but I just need the script. If someone can just give me something to start with and point me in the right direction, I can go from there.
Thanks,
MeatbagWammo
1) Put a sphere mesh into your scene
2) Remove all components except the MeshFilter from it
3) Add a mesh particle emitter component to the sphere (See instructions here, also add an animator and particle renderer)
4) Your sphere should now be emitting particles. Adjust the particles so they look like fire or however you want.
5) Create a new script and attach it to your sphere. The script to scale your fire could be as simple as:
using UnityEngine;
using System.Collections;
public class FireSphere : MonoBehaviour
{
void Update()
{
// Grow the fire in the X & Y directions
transform.localScale += new Vector3(Time.deltaTime, 0f, Time.deltaTime);
}
}
Use the Particle EMitter. It was created for such effects:
http://unity3d.com/support/documentation/Components/comp-ParticlesGroup.html
To make the fire spread: Change the elipse size you want.
To make "Clones" just identify the number of particles you want it to emit.
To make it disappear, set the time you want the particles to last.
To make the fire bigger, set the size you want it to increase to.
Finally, attach a script to destroy the emmitter object once you re done with your effects.
I added the sphere mesh and mesh particle emitter and it worked very well for me. Remember to select “interpolate triangles” in the emitter to avoid only emitting particles from the vertices. Here’s the source code I used (Javascript):
var growthInterval : float // seconds
var growthRate : float; // meters/second
var particleDensity : int; // # particles/meter
function Start() {
while(transform.localScale.x < 10) {
yield WaitForSeconds (growthInterval);
if (particleEmitter.emit) {
transform.localScale += new Vector3(growthRate * growthInterval,
0f,
growthRate * growthInterval);
particleEmitter.minEmission = (growthRate * growthInterval + transform.localScale.x) *
particleDensity;
particleEmitter.maxEmission = particleEmitter.minEmission;
}
}
}