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

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


airun2

Would this work for you:

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:

1 Like

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…

1 Like

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

1 Like

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! :smiley:

correctcast

castsuccess

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