Explosion.Visible = true/false

[quote] [quote=“StealthKing95” post=67232]Why do that when its easily scriptable! Heres some of my own code for “invisible” explosions

-snip-

How are they customized?[/quote]They rely heavily on the Explosion.Hit event and have custom damage settings. Having something that requires a touch event only appear for one frame is a really bad idea.

I want my explosions to be fully functional but invisible. Hence this request.

[quote] [quote=“TylerMcBride” post=67240][quote=“StealthKing95” post=67232]Why do that when its easily scriptable! Heres some of my own code for “invisible” explosions

-snip-

How are they customized?[/quote]They rely heavily on the Explosion.Hit event and have custom damage settings. Having something that requires a touch event only appear for one frame is a really bad idea.

I want my explosions to be fully functional but invisible. Hence this request.[/quote]

Damage could be simply done:

[code]
local totalradius = 20–the radius after which damage is 0
local killradius = 4 --the radius in which you will instantly die
–If you are between these the damage is calculated relative on your distance between these radiuses

local mult = ((totalradius - killradius) / 100)
local dmg = (totalradius - dist) / mult
dmg = math.floor(dmg)
whatever.Humanoid:TakeDamage(dmg)[/code]

Server replication is done at 20FPS, but even so, removing it 1/30 of a second later may still cause it to replicate, and then it would appear on clients’ screens for 1/20 of a second. However, this is not what the OP wants.

The custom explosion code down below could be easily edited to include a LuaSignal to simulate Hit. Even better, you could include extra code to show the distance the object was away, and how much damage it should take according to a certain wave function, if you wanted to get fancy.

To avoid API spam, I think all objects should have bools for PhysicsEnabled and RenderingEnabled. I also think that these things should not be able to be used by the client except local objects. So the client obeys the rules set by these bools, but they can’t set them. Read-only from the client to prevent massive abuse.

Bumping this. It’s even more relevant now that ParticleEmitters are out.

If your game is filtering, then in a local script

workspace.DescendantAdded:connect (function (obj)
if obj:IsA ("Explosion") then
obj:Destroy ()
end
end)

should work. It might do something funky for distributed physics, though. I’m not sure.

Doesn’t work. Explosion still shows up, davidii

Something unexpectedly tried to set the parent of Explosion to NULL while trying to set the parent of Explosion. Current parent is Workspace.

Besides, you need to wait() before instant creation/deletion. With it you still see the white/orange part of the explosion before it goes away

“Something unexpectedly tried to set the parent of Explosion to NULL while trying to set the parent of Explosion. Current parent is Workspace.”

You need to delete it in a new thread – not wait().

local explosion = createExplosion()
spawn(function() explosion:Destroy() end)

Thanks, that deletes it faster. There’s still a flash of white though echo. We really do need explosion.visible

Oh no doubt – I wasn’t arguing against it. The inability to set the parent of something right after it was created is an obnoxious gotcha that I felt you should know how to bypass.

[quote] “Something unexpectedly tried to set the parent of Explosion to NULL while trying to set the parent of Explosion. Current parent is Workspace.”

You need to delete it in a new thread – not wait().

local explosion = createExplosion()
spawn(function() explosion:Destroy() end) [/quote]

Try this instead:

workspace.DescendantAdded:connect(function(Descendant)
    if Descendant:IsA("Explosion")  then
        coroutine.yield()
        Descendant:Destroy()
    end
end)

@Finite: Nope :frowning:

[quote] @Finite: Nope :frowning:

[/quote]

D’aw.

Maybe this then! (server side code)

local function NewExplosion()
    local Obj = Instance.new("Explosion")
    Obj.Parent = workspace.CurrentCamera
    return Obj
end

Then you can use that as an in-place replacement for creating Explosions and they will only show up to the server (and hopefully still apply the explosion force)

[quote=FiniteReality]Maybe this then! (server side code)

local function NewExplosion()
    local Obj = Instance.new("Explosion")
    Obj.Parent = workspace.CurrentCamera
    return Obj
end

Then you can use that as an in-place replacement for creating Explosions and they will only show up to the server (and hopefully still apply the explosion force)[/quote]

This hides the explosion! It can still kill humanoids and break brick walls. But it stops applying force to loose parts after they were blown from a wall. Very weird and broken behavior

Also, putting the explosion in Terrain produces the same buggy results as putting it in Camera

Deleting the explosion or putting it under a camera is really hacky and messes with a lot of its behaviors/Explosion.Hit events, so that’s not really an ideal solution at all.

Explosions wait a frame before exploding IIRC. This implies that the same should happen on the client. What you could do is remove the explosion on the client as soon as it’s added. That way, the client shouldn’t see any explosion but the server should still work as expected.

Somebody may need to confirm this, you may also need to design an explosion handling script.

[quote] Explosions wait a frame before exploding IIRC. This implies that the same should happen on the client. What you could do is remove the explosion on the client as soon as it’s added. That way, the client shouldn’t see any explosion but the server should still work as expected.

Somebody may need to confirm this, you may also need to design an explosion handling script. [/quote]

Yeah, no, that doesn’t work. We already tried this, unfortunately.

It’s been about two years since I posted this thread, but I’LL BE DARNED IT SHOULD STILL HAPPEN. I want so badly to make custom particle explosions without the default effects taking place.

6 Likes

That is absurd, haha.

Heres a neat fact.
There is code in ROBLOX Battle directly ported from ROBLOX’s C++ explosion code, that allows you to implement explosion forces without an actual explosion object.

--world->ticklePrimitive(p, true);
--Vector3 delta = (p->getCoordinateFrame().translation - position);
local delta = p.Position - (Rocket.CFrame * CFrame.new(0,0,-2)).p
--Vector3 normal = 
--	(delta == Vector3::zero())
--	? Vector3::unitY()
--	: delta.direction();
local normal = (delta == Vector3.new(0,0,0))
				        and Vector3.new(0,1,0)
				        or  delta.unit

--float radius = p->getRadius();
local radius = p.Size.magnitude / 2				
				
--float surfaceArea = radius * radius;
local surfaceArea = radius * radius
				
--Vector3 impulse = normal * blastPressure * surfaceArea * (1.0f / 4560.0f); // normalizing factor
local impulse = normal * BLAST_PRESSURE * surfaceArea * (1.0 / 4560.0)
				
-- How much force to apply (for characters, ramp it down towards the edge)
local frac;
if isInCharacter then
	frac = 1 - math.max(0, math.min(1, (r-2)/blastRadius))
else
	frac = 1
end				
				
--p->getBody()->accumulateLinearImpulse(impulse, p->getCoordinateFrame().translation);
local currentVelocity = p.Velocity
local deltaVelocity = impulse / p:GetMass() -- m * del-v = F * del-t = Impulse
local bodyV = Instance.new('BodyVelocity', p)
bodyV.velocity = currentVelocity + deltaVelocity
local forceNeeded = 196.2 * p:GetMass() -- F = ma
bodyV.maxForce = Vector3.new(forceNeeded, forceNeeded, forceNeeded) * 10 * frac
game.Debris:AddItem(bodyV, 0.2/FORCE_GRANULARITY)
				
--p->getBody()->accumulateRotationalImpulse(impulse * 0.5 * radius); // a somewhat arbitrary, but nice torque
local rotImpulse = impulse * 0.5 * radius
local currentRotVelocity = p.RotVelocity
local momentOfInertia = (2 * p:GetMass() * radius * radius / 5) -- moment of inertia = 2/5*m*r^2 (assuming roughly spherical)
local deltaRotVelocity = rotImpulse / momentOfInertia 
local rot = Instance.new('BodyAngularVelocity', p)
local torqueNeeded = 20 * momentOfInertia -- torque = r x F, want about alpha = 20 rad/s^2, alpha * P = torque
rot.maxTorque = Vector3.new(torqueNeeded, torqueNeeded, torqueNeeded) * 10 * frac
rot.angularvelocity = currentRotVelocity + deltaRotVelocity
game.Debris:AddItem(rot, 0.2/FORCE_GRANULARITY)
11 Likes

Yeah, I’ve known this. Not a suitable alternative for an object, and especially a terrible workaround for something as simple as wanting explosions without visuals.

1 Like