Jump to content

Any easy way to spawn an explosion?


Recommended Posts

I want a command to spawn an explosion after creature death. However, c_spawn"gunpowder".components.explosive:OnBurnt()  spawns it under cursor, not in creature location. I tried SpawnPrefab("gunpowder").Transform:SetPosition(inst.Transform:GetWorldPosition()), but idk how to ignite it lol.

 I need to connect .components.explosive:OnBurnt()) and .Transform:SetPosition(inst.Transform:GetWorldPosition()), but idk how to do it too. If there are another ways to do so let me know!

Link to comment
Share on other sites

store the prefab in a variable then add any desirable commands afterward
e.g.
 

local kaboom = SpawnPrefab("gunpowder")
kaboom.Transform:SetPosition(inst.Transform:GetWorldPosition())
if kaboom.components.explosive then kaboom.components.explosive:OnBurnt()) end

 

  • Like 1
Link to comment
Share on other sites

22 hours ago, IronHunter said:

store the prefab in a variable then add any desirable commands afterward
e.g.
 


local kaboom = SpawnPrefab("gunpowder")
kaboom.Transform:SetPosition(inst.Transform:GetWorldPosition())
if kaboom.components.explosive then kaboom.components.explosive:OnBurnt()) end

 

Oh, thanks, It works just fine.

local function explode(inst)
	local kaboom = SpawnPrefab("gunpowder")
	kaboom.Transform:SetPosition(inst.Transform:GetWorldPosition())
	if kaboom.components.explosive then 
		kaboom.components.explosive:OnBurnt() 
	end
end

local function OnDeath(inst)
 inst:DoTaskInTime(0, explode)
end

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...