Why the particlefx didn't stop when its go has been deleted?

I have a weird problem to debug, I’m creating through a factory a GO containing an particlefx and a following script:

function init(self)
	particlefx.play("#fx")
end

function final(self)
	particlefx.stop("#fx")
	print("Deleted")
end

Then, when I delete this object I assume the particlefx should stop playing, but it isn’t, even when the “Deleted” is printed :confused: Where could I made a mistake?

I’m creating this object in module:

M.charge_fx = factory.create("#charging")

and then deleting it:

go.delete(M.charge_fx)

Spawned particles will not immediately be removed. They will live for the remained of their lifetime.

I know, but they still live and are spawned after the lifetime :confused:

Can you share a repro?

I couldn’t reproduced it in a new project, so it’s probably something rooted deeper in my project. I shared it with you, if you’ll have a time and will look at it I’ll be really grateful! :wink:

1 Like

I made a small workaround - I created a variable in a lua module that is initially set to false and when I want to destroy this particle, instead of sending a message to its script or deleting its GO, I set that value to true, and in update function of GO having this particlefx I’m deleting it when this value is true. I still can’t figure out why the particlefx.stop() doesn’t work, when I’m sending a message to stop it or deleting its GO and in final there is stop()… :confused:

function update(self, dt)
	if stats.destroy_charger then
		particlefx.stop("#fx")
		go.delete()
	end
end