Need a way to spawn an npc and despawn them properly ona trigger

Here’s my problem, I’m making an anomaly game, when a player passes through a trigger, it has a chance to spawn anomalies in the house and sets a variable “ Anomaly active”, currently I have a spawn actor at location when they pass through the trigger and the anomaly active variable is set to true, it’s nothing fancy It just checks if the actor is valid in the world, and if not fires a delay of 75 seconds, then spawn the actor and sets a boolean variable true that is spawned.

In this anomaly game, if anomalies are active, you turn around and go back through the start trigger, which resets the room to a normal state, and gets rid of the monster prowling around, which it does initially, however when the player does this and goes back through the trigger early before the trigger spawns the monster, it will still spawn on the next loop, whether an anomaly is active or not. I know it has something to do with the initial call to spawn the monster, when it checks if it’s valid in the world or not, but beyond that I’m not really sure what else.

Instead of worrying about the DoOnce just put a branch to check if IsDemonSpawned false then and only then can it spawn.

The problem is that DoOnce is being negated as soon as a demon spawns because it is being reset. Then when you destroy the demon you can set IsDemonSpawnedFalse and it will gate properly.

Also that 75 second delay, should be a timer that way if the room is reset you can nullify the timer so it doesn’t keep running.

On begin Overlap immediately disable the collision on the trigger component. Then call a timer to re-enable some seconds later. Do all your other logic after the timer call.

You mean like a set timer by event or function node?

Yeah exactly, just so you can call an invalidate if you don’t need it to spawn anymore, harder to do with a delay.

So how would I do that for this, I don’t have a function set up for this line of code or any events besides overlap trigger.

I’m making some assumptions here but I assume you have something like this?

Instead do something like this.

That spawn could be wrapped as a function or event it wouldn’t matter.

Yeah that’s generally what I have, I’ll try that out

You’re a legend that got everything fixed.

1 Like