Hi guys,
So here is my problem, I used a pawnsensor on my AI to detect the player.
To enable my AI to see the player I used “HasLineOfSightTo” in C++ code.
I tried to make a blueprint to solve the problem using lineOfSightTo node.
The first time the AI sees the player, it works the function returns true.
But if tI move the player to make it be out of the sight radius the function doesn’t return false, it continues returning true, as if the AI still sees the player.
here the player standing out of the sight radius of the AI: return false. That’s ok
What’s the type of your PatrollerController.Player variable? If it’s a controller then you should first get controlled pawn from it. Using controller here results in testing against controller’s spawn location.
Well, lineofsight does’t care about the sensing component it use a trace between 2 actors and doesn’t look at the distance. The way i do this is : Sensing component give you onSeenPawn event with a pawn reference, store that reference, and on your actor tick trace to this reference to know if you are still seeing it. You can use distance check between the 2 actors too. For example your cat comes into the dog vision, the event fires, and every tick(like 0.5s) you check if the dog is still seeing the cat : distance and trace check.
Oh ok that explains a lot. I’ve noticed that the sensing component has the function “haslineofsightto” I tried it and the same problem occurs. Doesn’t this function look at the distance neither?