Stop chasing the player

Hey, so I’m making a simple horror game where you have to use flashlight (flash the enemy) to stop them from chasing you. However, whenever I flash the enemies, they keep chasing, but if I manually set the “Is Flashed?” boolean to true, they don’t chase at all, so the boolean has the right effect.

I attached some screeshots of the player and enemy AI.


Thanks!

Hi @Acloed

You are setting the isflashed then delaying then resetting. Maybe you are holding back the code that controls what they are supposed to do.

Consider setting the isflashed then trigger a timer thats 7 seconds long which resets the isflashed boolean

Also i cant see how and when you handle the ai to stop moving when this variable changes

Hi there @Acloed, welcome to the Unreal Engine forums!

This topic has been moved from Community: Showcase to Programming & Scripting: Blueprint.

When posting, please review the categories to ensure your topic is posted in the most relevant space.

Thanks and happy developing!

An easy way would be to store the sensed player. If flash is true, empty the player variable and return to (maybe roaming? searching?) - or just sensing again

Hey @Acloed, welcome to the forums!

So what I would suggest is a cone trace for objects on your flashlight, and any objects with tag “Enemy” (Provided, set a tag for them!) you’ll cast to your Enemy BP and forEach on the array to “Get AI controller” >cast to your ai controller → Activate a Custom Event. That custom event needs to set “is flashed” to true, and have them do something else.

I suggest a timer or delay at the end of your custom event, that will be linked to a Gate node before your Sequence node. On event start, maybe use another custom event to close the gate, in line with the first custom event. After the timer or delay
on the custom event, open the gate.