Stop Ai Pawn Sensing

How do I disable an AI’s pawn sensing, and then enable it when player enters a trigger box.

This is what I have done so far for the Ai to follow the player around.

Hi, The pawn sensing work very well. You can ajust the radius of it. So I dont understand why you want to use a triggerbox. When the player is not in sight the AI will just continue his own job.

Hi thank you for your reply, basically what I am trying to make a game with two playable characters, you start as the first player and the AI I want to trigger is the second playable character. The reason why I want to trigger it to follow the player is because in the game you have to find the AI playable character and talk to it before it can follow you, so when you are roaming the map the AI automatically runs towards the player but I want the player to find the AI (maybe I am being a little too fussy). I also need to have the radius very high so if they loose each other or become stuck they can find each other without having to go back and get the other. But I did try to turn the radius down and the AI was not following behind smoothly :frowning:

Just put a branch before the “On See Pawn” attached to a boolean variable that is set to true once the player enters the trigger box. So until the player hits the trigger box, the boolean is false and prevents execution of the “On See Pawn” script until the trigger box changes the variable to true and then the “On See Pawn” script will execute and the AI will follow the Penguin.

Thank you for your help, I am new with BP so I don’t really understand, would it be possible to explain it in steps?

I will do one better, here are screen shots of a basic set-up. The trigger box script runs in the level blueprint, select the trigger box, then open your level blueprint, then right click in the editor and at the top you should see the option to “create reference to trigger box (or whatever you called it)”. With this reference, you can drag off a pin and type in “Bind event on actor overlap” and it should come up as I have laid out in the first image. Then in your AI blueprint, you can create the script in the second image. Let me know if you are confused by any of this.

Thank you very much! In the custom event for character overlapped, I added the actor reference to the inputs, is that right? I cannot find the trigger volume, I added it to my scene but I do not know how to get it into the BP

I figured it out!

Thank you for your help ! :slight_smile:

Ok, I was wrong, it does not work and I think it is because I did the trigger volume wrong :frowning:

The AI still automatically runs towards the player before entering the box trigger

haha same, and I think I did something wrong with the trigger volume, I tried to reference it in the BP but I probably did it wrong

Anytime! Glad it’s working for you.

Wow, I was just saying I was happy we solved it! haha So what is wrong with the trigger? Did you set up the trigger volume reference in the level blueprint?

So taking a closer look at your script, who do you want to follow whom? Because you have the trigger volume overlap actor as the human, and then you have the pawn sensing also in the human character. Maybe I misunderstood your set-up but if you want the human AI to follow the penguin (player character) then you’re looking for when the “penguin” since that is the moveable character…overlaps the trigger volume which would be near the human AI. When the penguin enters the trigger volume have it set a variable in the Human AI character that releases it’s pawn sensing behavior. I see from my screen shots I confused you haha I threw the script together in a character BP which also did the overlapping instead of making 2 separate characters for you. So what you would need to do to get it to work is this:

In Human BP/AI controlled character:

Create a boolean variable to control the pawn sensing behavior (you already did this)

In Penguin BP/Player Controlled Character:

Cast to Human BP or AI Class and store the output pin of the cast as a Variable to reference later
Create a new function which does the following

  1. get reference to AI
  2. From AI reference, drag off a pin and SET boolean variable created earlier to “true”

Level BP:
Have reference to trigger volume and on overlap cast to “Penguin”/Player controlled character, after the cast call the function created in Penguin/Player controlled character
Let the function do the work of setting the boolean in the Human/AI character

Also, I haven’t used this before BUT there is also a node (just thought of it) that says “Set Active”. You could probably just set it to be inactive on begin play in AI character, then when Player/Penguin overlaps trigger volume, do a double cast, first to Penguin to make sure thats what overlapped, then if true cast to AI and from the AI output pin get pawn sensing and “Set Active” to true. Should work in theory and is a little more straight forward. Try either option though :slight_smile:

I am not sure how to creating a new function because when I reference it to the human AI it changes from boolean

Here follow these steps.
In Penguin BP

In Human AI BP

In Penguin BP

In Level BP

An alternate method you can try…
In level BP

In Human AI BP

Can you send scree shots of your set up?

So, pretty sure I figured out the issue…just trying to find the best way to go about this now. But basically I forgot we are just creating a binding event in the level BP, we never “call” it so nothing after it is being executed…duhhh my bad :stuck_out_tongue: