x


How to make fire spread?

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

more ▼

asked Nov 05 '10 at 05:42 PM

MeatbagWammo gravatar image

MeatbagWammo
152 4 4 12

....MeatbagWammo?

Dec 01 '12 at 08:02 AM Aerovistae
(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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.

more ▼

answered Nov 06 '10 at 04:53 PM

denewbie gravatar image

denewbie
717 3 3 17

I'm not sure that the ellipsoid scaling can be done through script

Nov 08 '10 at 02:42 PM VS48

This does not work. The ellipsoid parameter cannot be changed via scripting.

Mar 05 '12 at 11:19 PM codingking
(comments are locked)
10|3000 characters needed characters left

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); 
    }

}
more ▼

answered Nov 05 '10 at 06:47 PM

VS48 gravatar image

VS48
550 3 4 15

(comments are locked)
10|3000 characters needed characters left

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;
    }
}

}

more ▼

answered Mar 06 '12 at 03:03 AM

codingking gravatar image

codingking
1 1 2 3

didn't work for me :(

2 days ago kakuridoji
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5069
x3454
x637
x151

asked: Nov 05 '10 at 05:42 PM

Seen: 2199 times

Last Updated: 2 days ago