Enemies stop attacking and moving after player respawns, how come?

This is for a Beat Em Up game template. Awhile back @Everynone showed me a simple way to make an enemy player seek the player without a nav mesh or AI tree etc etc. You can check that thread out here.

This is as far as I’ve gotten on an Unreal project btw (so I’m pretty excited). Here is the situation, like a typical Beat Em Up game you walk up till you encounter and enemy and the camera stops, and you are locked in with the enemy. You can’t advance untill you defeat them.

They approach the player, and will attack when right next to the player (Im still not solid on the enemy movement and attack mechanics).

BUT, when the third person character dies and respawns, the enemy will not attack, nor seek the player. I at one time had it where they would seek the player, but they would strafe walk and could not turn around to face the player, and would not attack again.

There would be so many screenshots to show this level blueprint. So I’m just going to try to use my blueprint ue to show it.

Any help is appreciated thanks!

Bump

Not sure if this can help but maybe it can…

So i have simple BP for my enemy they have the task to move to a fixed location if i come close to them in range they will try to attack me and follow me with pawn sensing. If i go out of the sensing range they continue on they’re path i set them to go. They dont care if i respawn they will still going to the location and aways attack me when i come close to them and start fighting me again and follow me till i get out of range or kill them and so it goes…

here is how it works and maybe you can implement some of it for your ai is really simple but works flawless so far…

1 Like

Player detection is just the sphere overlap, yea?

Might work to just clear the target variable and close the gate on the chase code from end overlap?

Or when player dies, call a function in the level blueprint which gets all enemies and clears their targets.

1 Like

Ok hopefully there is something I can use. The thing is though, i’m not using the typical AI set so the default AI stuff may not work. Thanks!

Well yeah, I have a gate that is being fed by an Event Tick (er the set timer looped equivalent of it), ok will check into thx.

bump

bump

Here is the simple logic that @Everynone suggested once to me that gets the enemy player to seek your player. It works pretty good. The problem is it seems it is only good for the first life of the player and possibly other things and then the players stop walking, and stop attacking.

Since this is a Beat Em Up template, here is the logic to make the enemy player instantly turn left and right like most Beat Em Up games.

And when I stopped it I was getting accessed none and pending kill errors.

I just made a video of it and you can see their behavior in this. When I made this vid, it seems that after he respawns they walk right past him like he is not even there…Hey I know the feeling lol…

Not really sure why it’s not working. Collision box attached to camera might just never be calling end overlap if it doesn’t move when player dies.

Might be safer just to add a Perception component to the enemies and set it up like this:

Might need to bump up the sight radius and peripheral vision a bit. And on player char you would need to add a Perception Stimuli Source component with sight config in the settings.

2 Likes

I’d never recommend something like this:

Hard referencing a character instance. When they die, the ref becomes invalid. How do you set it? Why not use Get Player Character instead?


a Perception component

This sounds like a great idea. Look up Pawn Sensing.

1 Like

Ok thank you.

Yeah try this with pawn sensing i mentioned that as well and it kinda works perfect for this stuff.

Btw your game looks fun reminds me of some oldschool beat em up like street rage

1 Like

Well, I changed it up a little hehe.

I’m getting the ref here off of Event Begin Play.

Ok for testing purposes today I will try to put it back just like you had it.

That feeds into this to keep them rotated correctly.

As of right now, they do keep punching and turning after a respawn, just not moving. And that kind of proves the gate did not stop the event tick or they shouldn’t be able to turn.

https://vimeo.com/839829037?from-to

1 Like

Thanks, I’m researching a lot of old Beat Em Up games trying to determine how the enemy moved. Ok I will need to figure out a way to implement pawn sensing a long with collision boxes. Maybe I could use pawn sensing just to get them to move. And collision boxes for everything else. Thanks for checking it out.

Here is a short 3min tutorial but very effective how to set up pawn sensing and then how the enemy character will move to you when they see you. In beat em up like your game i guess they should see you immidiatly, so make the pawn sensing range big enough. And then after they walk to you put your fighting code just after that and they will start fightning when they reach you.

Btw i see he is using unreal 4 and when you add the pawn sensing component you can click on it on your character on the left and on the right site in the details panel scroll down to “Event” then click “On see pawn”. Is the only diference if you cant find it like he do on his unreal 4 version the rest you could follow as it is and it should work.

1 Like

I have some more questions about this. Ok I added an AIPerception component to the Enemy player.

However I don’t see many options that you have. On my Target Perception Updated node, like yours on the bottom has the boolean output where you set that bool. What am I doing wrong here? Thanks

Also added an AI Perception Stimuli Source to the third person character. I assume that is like the homing beacon for the AI.

The gate needs to be closed in order to stop the code which comes after it.

As for the overlap itself, I think the problem here might be the overlap event isn’t triggered when if the player respawns inside of the trigger.

Work around for this would be to set the collision response to ignore in default for player, then turn it on after a short delay on begin play.

Or just use the perception component.

*Edit to add: To get the fancy options from the perception event, right click the stimulus pin, and hit Split Struct Pin.

1 Like

Yeah, their sight should be very high and with them instant turning to face you there should be no problem for them seeing the character. I watched that video. I don’t know much about AI but know you do need the nav mesh.

Thanks for the help!