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?
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
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,
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
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