x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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. alt text

Product Version: UE 4.17
Tags:
more ▼

asked Mar 12 '18 at 08:18 PM in Blueprint Scripting

avatar image

EmilyBec
18 1 3 7

avatar image Denis Lambert Mar 12 '18 at 08:26 PM

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.

avatar image EmilyBec Mar 12 '18 at 08:48 PM

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 :(

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Mar 13 '18 at 12:11 AM

avatar image

Nebula Games Inc
2.7k 14 8 8

avatar image EmilyBec Mar 13 '18 at 12:30 AM

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?

avatar image Nebula Games Inc Mar 13 '18 at 01:34 AM

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. alt text

avatar image EmilyBec Mar 13 '18 at 11:21 AM

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

avatar image EmilyBec Mar 13 '18 at 12:49 PM

I figured it out! alt textThank you for your help ! :) alt text

avatar image EmilyBec Mar 13 '18 at 01:20 PM

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

avatar image EmilyBec Mar 13 '18 at 01:23 PM

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

avatar image Nebula Games Inc Mar 13 '18 at 01:20 PM

Anytime! Glad it's working for you.

avatar image Nebula Games Inc Mar 13 '18 at 01:22 PM

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?

avatar image EmilyBec Mar 13 '18 at 01:35 PM

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

avatar image Nebula Games Inc Mar 13 '18 at 01:36 PM

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

avatar image Nebula Games Inc Mar 13 '18 at 01:46 PM

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 :)

avatar image EmilyBec Mar 13 '18 at 01:54 PM

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

avatar image Nebula Games Inc Mar 13 '18 at 03:12 PM

Here follow these steps. In Penguin BP

alt text

In Human AI BP

alt text

In Penguin BP

alt text

In Level BPalt text

avatar image Nebula Games Inc Mar 13 '18 at 03:20 PM

An alternate method you can try..... In level BP

alt text

In Human AI BP

alt text

avatar image EmilyBec Mar 13 '18 at 03:39 PM

Both of them are not working for me :(

avatar image Nebula Games Inc Mar 13 '18 at 03:46 PM

Can you send scree shots of your set up?

avatar image EmilyBec Mar 13 '18 at 03:52 PM

of course, Level BP, Human AI, Player alt text

alt text

alt text

avatar image Nebula Games Inc Mar 13 '18 at 04:06 PM

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 :p

avatar image Nebula Games Inc Mar 13 '18 at 04:24 PM

So, I got a basic set-up working where pawn sensing is "off" to start and turns on later. I don't have the rest of the functionality so there is no following behavior BUT the pawn sensing is working as expected. Here is what I did. In the Human AI, I added a "collision sphere" this will serve as the necessary trigger to tell when the Penguin has come close enough to be followed. Also, set the default behavior of the pawn sensing to not see pawns. Do this by clicking on the pawn sensing component, on the right hand side you will see the details panel of all the options, about halfway down is a box that is ticked by default that says "see pawns". Uncheck this box so default behavior is to NOT see pawns. Then click the sphere collision and use an "on component overlap" node, cast this to the penguin character, if true get the pawn sensing component, drag off from that and say "Set See Pawns", now check this box to be true. Your AI will now have pawn sensing enabled. Let me know if this will work for you. Sorry for sending you on a run around with the other stuff....didn't realize the binding issue until just now :/

avatar image EmilyBec Mar 13 '18 at 04:49 PM

No worries, I know nothing so thank you for your help! :) I am again confused with the bp but I am guessing it is this? alt text

avatar image Nebula Games Inc Mar 13 '18 at 04:52 PM

You got the collision sphere right, but not the right node. It is a red labeled execution node you are looking for. Click on the sphere component in the BP on the left hand components tab, once it is selected the right side details panel will change, scroll down to the bottom until you see a bunch of green buttons, on of those will say "on component begin overlap" that is what you are looking for, click on that and it will auto create the node for you. Use that to follow the above directions.

avatar image EmilyBec Mar 13 '18 at 05:10 PM

What should I plug into the target? I used the pawn sensing and the Ai rotated to the player alt text

avatar image EmilyBec Mar 13 '18 at 05:13 PM

I made the sphere big and it moves to the player if I am standing in the Sphere but when I walk out of the sphere the AI stops following :(

avatar image Nebula Games Inc Mar 13 '18 at 06:19 PM

You don't need the boolean value with this method.

alt text

alt text

avatar image EmilyBec Mar 13 '18 at 06:29 PM

Sorry for being too needy but it works perfectly! Thank you sooo much! :)

avatar image Nebula Games Inc Mar 13 '18 at 06:53 PM

No problem. Just glad we finally got it figured out :) I was worried this post was gonna get too long, only having to page down 5 times isn't bad right? haha

avatar image EmilyBec Mar 13 '18 at 09:50 PM

thanks to you! haha nope it is not bad! :)

avatar image Nebula Games Inc Mar 13 '18 at 10:07 PM

Yea I know, I take full credit for the length of this post....ha It's all good though, I remember being where you were. I was thinking of making some YouTube tutorials for people that have 0 coding experience (like me), (or at least 0 BP experience), since that's how I started I get the struggles. Hopefully that will cut down on the length of posts :)

avatar image EmilyBec Mar 13 '18 at 10:33 PM

It is horrible being where I am haha, YouTube tutorials are great! you should definitely do some especially when you know a lot :)

avatar image Nebula Games Inc Mar 13 '18 at 11:01 PM

It took me like 8-9 months before I stopped having to YouTube "How to make/do/fix X" for every game mechanic i wanted. In the beginning that's how it is, you have to look everything up, "make health bar" and "recharge health bar" are 2 separate tutorials haha then you figure out how the engine and your script are actually manipulating the variables, and what the nodes are doing behind the scenes and you end up being able to branch out past what was done in the tutorials and create your own novel behavior. Just keep at it you will get better and I will let you know if I ever put out some tutorials :)

avatar image EmilyBec Mar 14 '18 at 12:17 AM

That is quite quick to learn BP and definitely let me know and I will subscribe! Thank you for the help :)

avatar image Nebula Games Inc Mar 20 '18 at 09:57 PM

I started making some tutorials, if you need help with something else let me know I can make you a custom tutorial if I know how to do whatever. Here is one for overlap events if you ever have trouble with that haha

https://youtu.be/oAEs-BTliT4

avatar image EmilyBec Apr 14 '18 at 10:35 AM

That is great! I will have a look at them

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question