How can I establish certain behaviors as “legal” or not, so that my enemy AI will react accordingly?

Currently I have a behavior tree for my enemies that allows them to patrol, investigate, or attack. By default, as soon as the enemy sees my player, they attack. However, I only want the enemy to attack if it sees my player and if my player is doing something considered illegal (like trespassing). I’ve only been working in UE5 for about a week but I haven’t found a single tutorial that does this. I’m working on stealth mechanics similar to Hitman or Assassins Creed and this is something I’d like to implement, I just don’t know how.

In case anyone has the same problem, I ended up creating a bool that’s set to true under certain conditions. For example, if the item in my inventory is a gun, I set illegal to true, and from my AI controller, I cast to the player once the enemy sees me and if illegal is true, it enters combat, otherwise it stays passive. I did the same with a box collision to simulate a trespassing zone and added a widget to indicate the players trespassing. I had to use a few extra branches to make it work the way I wanted but it’s great now.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.