How Can I remove the events after fired Multigate node?

I’m making various things happen every time the trigger box is touched. I want to add different effects each time using the multigate node, as shown in the image above. Is it possible to remove the already spawned AI character or revert the effects as if they never happened when the trigger box is touched for the second time, and then spawn new effects?

++
recently I add ‘Do once’ node to prevent Trigger box fire same event. But still don’t know how to remove the events already fired

1 Like

Hey @shallow!

So there isn’t an “Undo Function” or anything. But, you can usually find a way to reverse things.

For example, with your SpawnActor, take that return value and promote it to a variable.

Then, on the next one, use the Destroy Actor node and pass in that variable, which would be the actor you spawned on the first Out of the MultiGate.

If you want it to be random, you can make a function out of it (maybe call it “Undo SpawnActor Out 0”) and have the function use that variable, use a gray “IsValid?” check and on True, destroy actor, then put that function before the MultiGate. You could make reverse functions like this for every possible branch to “reset” any branches before choosing a new one.

Hope that helps and let us know if you need more assistance!

3 Likes

Hi I followed your solution, and little bit hard to understanding

Let me show you my blueprint

And this is my function Graph which you told me to create

I run the game with this script, and actor never appears… haha

I am very new to developing… Can you teach me more specific? ㅠ_ㅠ

1 Like

No worries! Let’s move some things around.

Firstly, you have to set your value of your variable. I don’t know what to call it, but definitely don’t leave it as “NewVar_0”.
image

Next you want to use this isvalid? check inside the function. Make it be the first thing, and GET your variable “NewVar_0” and pass that into the “Input Object”.

What this does is prevents a crash in the case of the variable not being set, or being empty. If it is empty, it is not valid, and so it does not try to DestroyActor.
image

Thirdly, this doesn’t need to be a “Set”, because you’re not setting it here.

You can use the same “Get NewVar_0” you use for the IsValid? check!

Give that stuff a try and let me know how it goes! :slight_smile:

It works!!!
Thanks for the details . hahaha :slight_smile:


Hope you have wonderful day sir :)))

1 Like