I’ve had trouble destroying specific effects as the last created entity is the only one I’ve seen working for me. Help would be greatly appreciated as I really need to destroy a specific effect for a custom hero instead of all effects
It changes from time to time but usually the best way to do it is just right after you create the effect set a global/player variable to last created entity, and then destroy that variable.
Ok Thank you! ^^ I will try that immediately
@Leader’s method does work, but it won’t if you have multiple effects spawned in short amounts of time.
I’ve been making a PvE mode for a while that’s supposed to have a “spawn beam” effect, that gradually shrinks and then disappears, but each time an A.I. spawns, a new teleport beam effect is spawned. This method ends up with effects that cannot be deleted because an effect is always being spawned on top of it. Think of it like layers. The first layer has 1 effect, but before you can remove that layer, the 2nd layer appears, and the 2nd layer is what gets deleted. Then you’re stuck with the first layer, which will not go away.
You can try to use an Array system that stores each and every effect in it’s own unique index. Then, you can delete the effects based on the index positioning and not have to worry about them stacking, for the most part. I don’t know too much about using the array’s for storing effects, as they have always given me trouble. I just use play effect now. Much easier, less buggy, but has less potential… ;-;
Are you storing these new effects to the same variable? And is that variable global?
You should use the array like a queue (first in first out):
As initialisation you use: set global variable(A, empty array)
Then, whenever you create a new effect you use: modify global variable(A, append to array(last created entity))
Whenever you want to destroy the oldest effect you use these 2 actions: destroy effect(first of(global variable(A)))
modify global variable(A, remove from array(0))
However it would be easier if the Devs add “Duration Time” as Syntex to “create effect”, that could save a few variables.
Like someone mentioned about Spawn Beam, I guess its temporary and will be vanished in 5 sec. for example.
Play Effect as alternative, but the choice of effects is very small.