I am creating my first game and for it I am trying to put together (what I imagine to be) a very simple horror game enemy AI. The only thing I need it to do is be able to switch between 2 states, chasing the player, and roaming. I have a tree set up from root to a selector with three branches, the first priority is to Chase Player. If CanSeeTarget is set to True than the AI will move to the Character. If it is set to false AI will FindRandomLocation within a radius of 10,000 => MoveToLocation => Wait 5±2s and repeat. If for some reason both of those fail, I have a wait task set up as a contingency before it starts the process all over again. The issue that I am having is that once the AI gets sight of the player, CanSeeTarget will never be false again. I can turn corners, even jump into a lake on my level and swim to the bottom and CanSeeTarget is still set to true. Can AI see through landscapes and objects naturally? Or is this a programming issue?
when do you set “CanSeeTarget” to true, and when do you set it to false again?
If with “see” you mean the sight sense of the AI perception component and your landscape and objects are set to block the collision channel that the sight perception uses, then no.
I am using Pawn Sensing, so whenever the player is in the AI’s FOV, then Can see target is set to true. I haven’t specified a time that it is set to false. This is my first behavior tree, do I need to explicitly tell it when to break line of sight from the target? The “see” I’m wondering about is whether or not the Pawn Sensing’s “vision” can penetrate objects.
If “CanSeeTarget” is a bool that you manually created, then yes.
By default the sight sense uses the “Visibility” collision channel. Therefore all objects that block this channel will block the sight of the AI.
It was indeed a Bool issue. I just added an additional function in the blueprint and set it to false so no I had the ability to break LOS. Thanks for the speedy response!