Making Fire Sand
Let's try another favorite, fire. A material that turns other burning materials to fire. And dies after some time.
Create new sand
Create new sand by copying another one.
Give your sand a new name, fire, fire-like color and toggle the variate, blur, Extend Radius flags on under the visuals.
Physics settings
Fire is going to be a gas like material, liquid that moves upwards - to the opposite gravity direction. Give it the following physics settings.
Fire moves up, behaves like liquid, but is affected by forces normally.
Rules
First behavior we want to add to fire is that it should die over time. Edit the graph to be like this.
This rule now says the following: With probability P < 0.1 (each frame), turn fire to empty, else remain as is.
You will now see fire die after some variable time.
Now all those fire sand move very similarly to each other. To simulate sparks, it would be nice if some fire sand moved slower than others. Let's do that.
Let's change the graph to following.
The difference here now is that we wish to turn some fire to a new fire, which means that their velocity is reset to 0.0. Else stay the same as before. This way some fire will move slower than others, creating the sparks like behavior.
We're using Math: Random with seed
to get a different probability from the Math: Random
, and we consider the
else
case where sand did not turn to Empty
.
Basically we're saying:
With P1 < 0.1, turn fire to empty. Else, with P2 < 0.1, turn fire into fire, else remain as is.
Fire now looks like actual fire with sparks.
Using Random with seed
ensures you can generate multiple random numbers with different P within the same graph.
If you only use Random
, all your P within the same frame will output the same value. That is, because they are
seeded with position
and time
, and within the same frame for a single function, these are the same. For seed
use offsets of 0.0-1.0.
.
Reaction
Last thing missing is fire burning other sand. Add the following characteristic to fire: BURNS
.
And to any sand material you wish to burn, add the following.
Now fire should burn your desired other sand.