How would you make an enemy AI react to a certain event or action? For example, the AI attacks when I show my gun or show it

I am trying to create a simulator where an enemy character or ai reacts based if they can see my weapon or if I am aiming at them.

1 Like

I’m assuming you are using your using blackboard or similar setup for your AI. The simplest way to make then react is to flag your player has having gun visible when you pull it up. Then you can check the flag during AI processing and handle when the flag is true or false as you see fit. To determine if you are pointing at them do a line trace from your character every tick, or every few ticks, to determine if your player is pointing at an NPC. If your player is then set a flag on the AI with a timer to auto clear and again check the flag during normal processing of the AI.

1 Like

Hey that’s definitely something I thought about doing. Thanks for your help.