Looking for help with "enemie respaw"

hello again, first of all really thanks and i’m really happy because finally i’ve feeling the forum being more “helpfull and newcomers friend” than it was in the past and i’me getting really some help which was something not happening for some time, really thanks.

going back to the topic, i’m working on my project and i’m currently working on the “enemies” and while i’m already working in the AI, i’m currently stuck in a issue which is about the “respaw”, while i’ve managed to make the Enemie “respaw” it not working as i wanted then i want some help on that.

here the issue:

if possilbe i want 2 ways to respawn the enemy to choose one or either.
1 - respawn after dead, after i’m killed the enemie it will take a “delay” like 10s after that the enemy will respawn again on his start point don’t matter if i’m here or not, in case i need to come back to that place to not be “empty”, then each time i kill the enemy it will respawn after a Cowndown(delay) in his start point.

2 - respawn when “not looking”, almost the same as the first but the delay or CD only start to count after the “camera” or character leave the spawn place, then it start the cd then spawn back the enemy on his place.

i would love some help on how to do it, i’ve already tried some stuffs but the best thing i’ve did was make it respawn after the first one get killed but it trigger a “endless respawn” of enemies which is obvious not what i want or it only respawn a second time then never spawn again.

i want then to spawn after they get killed like if health = 0 delay like 5 to 10 seconds then it respawn again or in the case of the camera after i leave the place the delay start then the character spawn again and will be waiting for me to when i come back.

any help would be awesome.

Hi @Ellessarr

It seems simple, but you can manage it in many ways,

To know if you still are in the area and dont want the respawn,
you can surely crete some triggers , or check just the distance from the player to the respawn point.
What exactly you have problem with?
take a look at this Check if player is in an area - Programming & Scripting - Unreal Engine Forums

the only thing i was able to make was or make the enemie spawn endless after the first one get killed, then it trigger a endless spawn of enemies which keep spawning even if the previous one still alive, or make it spawn only a single time after dead.

what i want is after i kill the enemie, or it wil respawn after x seconds passed again, or after i leave his spawn zone then or it trigger a small delay then spawn a new add or after leave it spawn again a new add.

in both case i need a "sort of loop, where each time the enemy of the spawn zone is killed a "new one replace it but only after the previous die and only 1 per time, not keep spawning forever.

Well,
you can just use your enemy, once get killed , you leave it exist, you can delete the mesh or just hide it … and keep it so you can add a delay to check , every 10 seconds if the player location - the spawn location is < of 300.
Then you have to break the loop.

If you have a “enemy spawner” you can do it inside that.
Once the enemy is killed , he send a custom event to the spawner ,
he will check every 10 seconds if the player location - the spawn location is < of 300.
Then you have to break the loop.

To break the loop you can use a loop connected with a gate node to that can turn off himself
here the page with the flowwwss

1 Like

here my spawnbp

the begin event play works fine, it spawn the first “ai”, then i created the integer to “respawn” the npc, the idea is when npc dies the integer will be set to 0, then the tick will see it as “0” then respawn the npc, this is for the “per time”.

Going for when the character leave i was planning in using a collision box, then when the character leave the box or "end overlay it will check if the alive is 0, if it’s 0 then it will respawn.

the problem going to the enemy bp

the issue for me it’s seens before the destroy actor how i can call or make a reference to the enemyspawn BP to set the alive value to 0 for the tick to know which now it’s 0 and can now spawn the enemie again, i’ve tried som cast to but failed terrible, i really don’t know what to cast or call.

ok after found this tutorial:

i’ve managed to make this:

now it’s proper spawning after 10s seconds each time te enemie dies, now the thing is the "spawn based on the spawn location, any idea how i can “change or improve it” to also detect a collision box?? just need to know how to proper add a collision box event based on overlaping end, when the player leaves to collision box it trigger the spawn again like by time but with the collision.

To check ovelapping:

1 Like

hmmm thanks the second one worked for me.

the first one seens more related for when overlapping and in my case was about “when not overlaping the spawn zone”.

really thanks for the replays.

really awesome help and support again really big thanks for your attention and help.

Hi!

For the timed one, you’ll want to spawn the enemy then bind to when it gets killed or destroyed.

When the killed/destroyed event fires off, you set a timer for however long, then you call your spawn function again, which again binds to the enemy being killed/destroyed.

The second option you mentioned is a little trickier. You could check on the player’s tick if their aim direction is close to looking at the enemy spawn point, and if it is, you reset a timer on the spawner. That way if the player ever goes long enough without looking at the spawn point, the timer will go off and spawn a new enemy.

1 Like

interesting i will give a try later thanks too!!!.