Putting out fires realistically?

Hello,

So pretty much I have a very simple fire system, it either goes off when the fire alarm is pulled or the smoke detector detects smoke or fire in the building, then the fire alarm plays and sprinklers go off. I was wondering how I could make this as realistic as possible so if the sprinkler is hitting fire, the fire gets put out in that specific area. My other lazy way of doing this back then was just have the fire on a wait function when the sprinklers were turned on, it would wait 30 seconds and the fire would go out. I’m gonna go for the raycasting approach, but have no idea about the math as that isn’t my kind of thing. Anyone got any ideas?

Demonstration shown here

Thanks!

3 Likes

Hrm this is an interesting question indeed, What you could do is spawn an invisible cube that detects around the area, then have it use heartbeat to tick away at the intensity of the flame until it reaches zero, but that’s just an idea of what I would do

Optionally, you could probably get a list of objects within a certain magnitude of the sprinkler, rather than doing a collision, which would probably be less intensive, i’d just use iterating with care if you do it that way

3 Likes

Ahh yeah, I never thought of getting magnitude, I’ll look into that and then see if it’s a fire, if it is then I’ll wait a couple of seconds and just destroy the fire. I’ll mark this as solution if this works,

Other ideas are more than welcome!

1 Like

Maybe slowly decreasing the size of the fire is effective. You can do that by GetTouchingParts() I think…

1 Like

Indeed it is a good idea, however, rather than using wait, i do recommend using either heartbeat, or renderstepped, and slowly tick it down, as wait seems a bit un-needed in this aspect, unless you just want it to instantly die

1 Like

Yeah I was just using it as an example, I’ll probably use heartbeat or renderstepped, just going to experiment first. Thanks!

2 Likes

If you wanted to make it so the fire was put out in a cone shape down from the sprinler. Then for each fire check if:

math.acos((firePart.Position - sprinkler.Position).Unit:Dot(Vector3.new(0, -1, 0)) < math.rad(45)

and if true, put that fire out. You could make this more efficient by using

GetPartsInRegion3WithWhitelist()

around the sprinkler to reduce the number of parts you need to test.

2 Likes

I’m not too sure how I could do this, I have multiple sprinklers and there may be multiple fires so I don’t know how I would make the variables. If you have any idea please let me know!

With some help from a very nice user, we got it to work successfully, it may not be the best way but it works, here’s the actual code part for it if anyone wants it:

	for i, v in pairs(workspace:FindPartsInRegion3(region)) do
				local fire = v:FindFirstChildOfClass("Fire")
	
				if math.acos((v.Position - sprinkler.Emitter.Position).Unit:Dot(Vector3.new(0, -1, 0))) < math.rad(45) and fire then
		
1 Like