- Home /
Too subjective and argumentative
how to spread a fire?
Answer by Fornoreason1000 · Dec 04, 2013 at 06:08 AM
one way to do this .
Breifing
ou could ray cast around the start pos of the fire for flammable materials. then instantiate flames around the objects. then basically make it continue. by duplication.
Overview
start the fire.
Every few seconds preform ray-casting logic.
using tags, you can determine how well something is flammable.
if the target is flammable, get its collision bounds and instantiates some flames. based on the coordinates
repeat the process a few times to build up.
after a certain amount of fire, duplicate the start to the ray cast locations to allow it to spread further.
Starting the fire
ou can do this a number of ways. basically you want to setup a small particle system. containing the flames, you also want a prefab for the additional flames you are going to use to spread the fire. with the new shrunken particle system, it should not take long, ideally you can add a light with a red color. you can also make it grow from the start up to add some realism.
Ray casting Logic
irst of all you want to make sure ray casting doesn't happen each frame as this can be very slow! Instead in your script you want to add two variables MaxSpreadTime and MinSpreadTime. the when another variable is equal to a random number between those to you will start the spread logic.
The spread logic is quite simple, you simply use Sphere cast to check for anything around the the fire. then we can get the hit parameter.
Is it Flammable
here many way you can do this. one was is by using tags. you may have it already set up with things like Steel,Wood and Concrete. you can use the .hit parameter to find out if you got the tag or not. obviously thing like steel and concrete are not flammable but wood is, so you would check if hit.gameObject.tag is equal to the wooden tag.
another way is by component. you check make a new class called Flammability. this is useful for when there are gas tanks and explosives with steel containers. hit.gameObject.GetComponent suits this well. the beauty about this is that you can set how flammable something is, e.g wood is less flammable than petrol. you can set how long the flames will last for if you're talented.
@yogee, You do realize the scope of what you're asking, right? This is not a question that has a "right" or even a "best" answer. @Fornoreason1000 is giving you the rough outline of the first 6 steps you could try, but this is quite literally the kind of thing people do thesis projects on.
I am marking @Fornoreason1000's answer as correct and closing this question, because what you want is impossible to describe in a few paragraphs. This is much better for the forums, where you can have an ongoing discussion and possibly collaboration with other Unity users.
Follow this Question
Related Questions
Fire particle problem. 1 Answer
Two Particle Systems 1 Answer
How can I get an object to recognize it should be on fire? 1 Answer
Particles - Moving a long 1 Answer
Fire outline shader 1 Answer