Boolean Being Set to True at wrong time

Hi, so I’m trying to create a little AI system where when the AI goblin sees the player, it runs away and hides. But for some reason, the boolean that I have that determines if the goblin sees the player is being ticked to true even though the player shouldn’t be visible to the goblin. When going down the behavior tree incrementally, it only hits 2 nodes before aborting to the branch where the goblin sees the player. I looked in the blueprints where the goblin just wanders around and where the 2 nodes are run and I don’t see any place where the boolean is being set at all.



The First picture shows the wandering branch, the second picture is the branch it aborts to, and the final picture is the only node being run where I made it myself with my own code before it sets to true.

One thing: try to put the Wandering branch to the left side of the Selector and the branch it aborts to to the right side. The selector always starts to run from left to right, so wandering is the default and can be interrupted, if the condition is not met any more by adding an abort condition to the decorator.
Somewhere else in your code, the CanSeePlayer should be set, typically by an AI Perception component.

The problem lies here where it’s calling Sees Player. I’m not sure why it’s running that because the AI shouldn’t be able to see the player because there are massive walls between them.




Hey @Zapking9224!

I see you are using the AI Perception component, but I don’t see where you are utilizing that components sight or anything similar. Have you tried implementing the Get Currently Perceived Actors using the sight sense?

image

Here is the UI documentation on perception nodes available:

Hopefully the above helps point you in the right direction!

I was using on perception updated. I wasn’t sure exactly how to differentiate between sight and hearing perception so I tried tagging the footstep sounds the player would emit as “Sound” as the stimuli source. Your idea with the “Get Currently Perceived actors” looks helpful but I’m not sure how I would utilize it. And I can’t find anything online about it aside from what the node itself does.

Hey @Zapking9224!

If you are trying to directly set sight (your goblin may hear the player) as your stimuli source, you should do so directly on your character. Add an AIPerceptionStimuliSource component to your player. Then in the detail panel with that component selected, go to AI Perception → Register as Source for senses, then add AISense_Sight to the array.

ZBSuMIJTFk

From there, you should check this non-Epic affiliated youtube video that goes through the whole process:

Hopefully the above is the solution you need!


Ask for the class used

That’s the node I was looking for! Thank you!