- Home /
Question by
dragonpowerful · Feb 22, 2012 at 10:00 PM ·
firespread
How to make spreading fire
How could I make a script to make fire spread across the screen slowly by cloning a new particle system next to the original one
Comment
Wiki
Answer by joe_carrot · Mar 25, 2013 at 09:27 PM
You'd want to clone your particle system every preset amount of time. The only tricky part would be making sur ehte fire does not appear in a place that there already is fire.
To just clone the fire, you'd use a script like this attached to your fire particle system:
private var startTime : float;
var pollTime : float = 5.0; // Seconds between fire spreading
var spaceToSpread : Vector3 = new Vector3(1,0,1);
function Start()
{
startTime = Time.time;
}
function Update()
{
if(Time.time > startTime + pollTime)
{
startTime = Time.time;
CloneFire();
}
}
function CloneFire()
{
var newFirePos : Vector3 = transform.position + Vector3(Random.Range(- spaceToSpread.x, spaceToSpread.x), Random.Range( -spaceToSpread.y, spaceToSpread.y), Random.Range(- spaceToSpread.z, spaceToSpread.z));
var newFire = GameObject.Instantiate(gameObject, newFirePos, Quaternion.identity);
}
Your answer
Follow this Question
Related Questions
How do i make fire spread 1 Answer
[Unity2D] Make fire spread through tiles in Platformer 0 Answers
Spreading Fire (Bullets) 3 Answers
Need some help with bullets spread fire!!! 1 Answer
Randomized Gun Spread 1 Answer