I am having a weird issue with my AI. When I run the behavior tree and I am standing behind the AI character, the AI senses me, goes to turn a frame, then loses sight and regains sight, and repeats. Also if I walk too close to the AI and go out of his cone of vision, it repeatedly fires true and false on the AI Perception Updated component. Why does the AI see me when behind him and why does it fire true and false at the same time like this?
So firstly, you’ll want to take out that sequence before the selector on your second branch. It’s useless to have here, and unless you plan on having another branch where the selector returns unsuccessful it’s bloat and just something to trip over- even if you do add another branch, I’d take it out for now.
Next, add a decorator on the sequence for “IsInvestigating is Is Set” so you have one path for true and one for false (I know, it shouldn’t care, but just to be safe. It’s strange how picky it gets).
Lastly, put the IsInvestigating IS set on the earlier branch, because you want it to take priority.
Try those changes and see if anything is different!
I took your advice and removed the sequence before the selector on the second branch. It was placed there with the intent of adding a caution stage later on, but you’re right- it’s not needed now. I also moved the decorator as you said, and added one to the earlier branch.
Unfortunately, the problem still seems to persist.
I noticed in my AI Controller the On Target Perception Updated node is repeatedly firing during this issue as if the AI is seeing me behind them and then losing sight which is bouncing the behavior tree between moving to the target actor and moving to the target location. If I disconnect everything from the behavior tree, the AI will only detect me when it’s in front of me, but once it is receiving commands from the Behavior Tree it goes wonky.
I’m wondering if it might have to do with the orientation of the AI Perception component not lining up with the rotation of the NPC, because it seems to only occur when they are turning. Almost as if the perception component is snapping to the new direction before the Character, causing it to snap back and forth between the new direction and the current rotation of the AI Character as he turns.
I can see On Target Perception Updated firing continuously. It prints True and False on a loop (from stimulus successfully sensed) and continues until the AI finishes it’s rotation toward the Player Character.
I think with the added info, it’s possible that yes, it has something to do with your sight component lining up with your character, so we’ll need some pics of the character BP- I’m thinking something to do with the AIPerception’s “Senses Config”!
I am not entirely sure as I gave up the project to work on something else, and unfortunately when I just went to look for it I couldn’t find it in my library, so I must’ve deleted it entirely.