# How to trigger an event in Character blueprint from AI controller blueprint?

**URL:** <https://forums.unrealengine.com/t/how-to-trigger-an-event-in-character-blueprint-from-ai-controller-blueprint/1315524>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [September 28, 2023, 2:56pm UTC](https://forums.unrealengine.com/t/how-to-trigger-an-event-in-character-blueprint-from-ai-controller-blueprint/1315524 "2023-09-28T14:56:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vizorsnix](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@vizorsnix](https://forums.unrealengine.com/u/vizorsnix)\
**Post date:** [September 28, 2023, 2:56pm UTC](https://forums.unrealengine.com/t/how-to-trigger-an-event-in-character-blueprint-from-ai-controller-blueprint/1315524/1 "2023-09-28T14:56:37Z")

</div>

Hello,

I am trying to make the AI run when they sense the player, I’ve set up the AI Controller to be able to handle sight, and have some basic stuff set up in the behavior tree such as patrolling and chasing the player on sight.

I’m trying now to make the AI run when they see the player, basically I want to make an event to change “Max Walk Speed” in the Character blueprint and ‘call’ or trigger the event in the AI controller blueprint.

I don’t know what to plug in to the “Target” in the event being called. “Get Controlled Pawn” doesn’t seem to go in there. Any advice? Thank you

 ![airun1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/4/b/f4b7fe647b00e6784ba59778518142823928b5e9.png)  
 ![airun2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/a/8/aa822f99ea53c4ad6ce3d8f318215235c3f98e16.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [September 28, 2023, 3:20pm UTC](https://forums.unrealengine.com/t/how-to-trigger-an-event-in-character-blueprint-from-ai-controller-blueprint/1315524/2 "2023-09-28T15:20:37Z")

</div>

> [@vizorsnix](#):
>
> I’m trying now to make the AI run when they see the player

Would this work for you:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/e/d/0eda1ffb4efa75f2a7ef8816cf5b1f7e48cf6d4b.png)

The above gives you the pawn that triggered it and an instigator (in case you can make noise elsewhere - throw a lure or something). Pawns can’t hear if they can see you, btw. Here’s a crude example:

> [@AI Character move away from pawn but stop after some distance.](https://forums.unrealengine.com/t/ai-character-move-away-from-pawn-but-stop-after-some-distance/786232/2):
>
> Hard to recommend anything specific since we don’t know how you’re doing things atm. Perhaps you could take advantage of Pawn Sensing, If the AI detects Player Pawn, they run away in the opposite direction: You get to control some params here. If no Pawn is detected, the AI can return to whatever other routine you set up. You could use a sphere overlap on the player pawn to send the AI away in a very similar way instead of the Pawn Sensing comp.

---

<div class="post-metadata">

**Author:** ![KiiroiSenko](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kiiroisenko/32/754874_2.png) [@KiiroiSenko](https://forums.unrealengine.com/u/KiiroiSenko)\
**Post date:** [September 28, 2023, 3:30pm UTC](https://forums.unrealengine.com/t/how-to-trigger-an-event-in-character-blueprint-from-ai-controller-blueprint/1315524/3 "2023-09-28T15:30:22Z")

</div>

You need to cast the controlled pawn to the BP class where you defined the event so it goes in the target. Basically you need the same class or a subclass of the BP that defined the event.  
Get controlled pawn gives you an APawn object which as far as compiler is concerned does not have the event you defined…

---

<div class="post-metadata">

**Author:** ![vizorsnix](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@vizorsnix](https://forums.unrealengine.com/u/vizorsnix)\
**Post date:** [September 28, 2023, 3:58pm UTC](https://forums.unrealengine.com/t/how-to-trigger-an-event-in-character-blueprint-from-ai-controller-blueprint/1315524/4 "2023-09-28T15:58:06Z")

</div>

Ahh thanks, yes I guess I could work with a Pawn Sense. Actually it’s probably exactly what I need. Thank you 🙂

---

<div class="post-metadata">

**Author:** ![vizorsnix](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@vizorsnix](https://forums.unrealengine.com/u/vizorsnix)\
**Post date:** [September 28, 2023, 4:02pm UTC](https://forums.unrealengine.com/t/how-to-trigger-an-event-in-character-blueprint-from-ai-controller-blueprint/1315524/5 "2023-09-28T16:02:39Z")

</div>

Do you mean like this? I tried to cast to the pawn in the AI controller to get a reference, but it didn’t work anyway. Thank you for your reply

Edit: I was totally doing it wrong, I got it, thank you thank you! 😃

![correctcast](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/2/b/02b5cee5fc2e6d58f187da73e1e8c0f25f93383e.png)

![castsuccess](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/a/5/ba54e30df4ee202af3984f2e49de70e95ed5a29a.png)

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [October 28, 2023, 4:03pm UTC](https://forums.unrealengine.com/t/how-to-trigger-an-event-in-character-blueprint-from-ai-controller-blueprint/1315524/6 "2023-10-28T16:03:12Z")

</div>

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