How to have AI detect collision hits from physical objects

Okay in my game I want to make it so that when a projectile hits my enemy AI the AI will get stunned for a little moment. However, I can’t seem to get that functionality working for whatever reason.

So this is what I have set up:

-All logic and blueprints the NPC is using
image

In the character blueprint I made it so whenever the character collides with the projectile it sets a bool to be true.
image


image

Then I try to reference the character blueprint in the AI controler to get the “IsStunned” bool and use that as the “Bool Value” for the blackboard bool.
image



(the blackboard key bool is also called “IsStunned” sorry if thats a little confusing)

Then I tried to make it so that the “Stunned” task will run if this bool is true then In the stun task I set the “IsStunned” bool (That is in the character blueprint) to be false.

That didn’t work tho! I think the issue arises when i try to reference the character blueprint in the AI controller blueprint but I don’t know how to fix it.

Do any of you all know how to fix this? Is there a better way to do hit detection that is simple?

I’ve tried looking up some tutorials but they all seem to confusing or not relevant to what I want.

A lot of the tutorials I’ve seen focus on melee combat or line tracing, I don’t reallt want that. All I just want is to make it so when the npc collides with the projectile actor it will stop all tasks, stay still and play the stun animation, then resume its tasks.

For note I am an Unreal Engine 5 beginner (started using it about 3 months ago) that used to use Unity.

From what I understand I think the problem is here

First of all, is there a reason you use “Get all actors of class” instead of using “Get controlled pawn”?
Secondly, you are setting the “IsStunning” key only on begin play, shouldnt you do it every time it is updated?