Negative pawn sensing and AI perception?

Hello! I’m working on an enemy that works like the Weeping Angels from Doctor Who (they stop moving when looking at them, and move again when no one is looking at them). I’ve followed this tutorial: https://www.youtube.com/watch?v=XUFKEJRTaGg&ab_channel=MattAspland

I want the enemy to kill the player when it touches them, but only if the player is not looking at it. How can I check if the player is or is not looking at it? Variables are not working, checking if the enemy movement is active doesn’t work either. How can I know the enemy is in the player’s viewport or not?

Is there another way to code an enemy like this?

simple way would be to use the dot product of the camera forward vector and compare to the enemy direction.

dot prodcut will give a value between -1 (behind) and 1 (facing) so anything less than say 0.2 could be considered off screen

Hey there @JasonKorda! So if the tutorial went over well and the enemy is stopping, you only need to set a boolean to true when they are in view and false when they aren’t, and when colliding with the player, check that boolean to see if they are being looked at with a branch, if true do nothing, if false kill the player.

Though if you don’t like the perception method, and you want an alternate means of detection, you could look into using recently rendered:

But then I’d have to be staring directly at it, so if the enemy is in the corner of the screen it would be able to move or does it work differently?

Thank you! I think this gets closer to the answer I was looking for, but it’s not working for me. It returns true even when the actor is not on screen… Am I doing it wrong?

I’ve also tried “Was Actor Recently Rendered” and the result is the same :frowning:

Update: I increased the pawn sensing peripheral vision angle, but I’ve the pawn sensing vision doesn’t rotate with the camera. Is there a way to make it follow the camera?

nah youve got a whole range which you can tweak, so like i said try something like is dot product <0.2 and adjust that 0.2 as you like

i use this for flanking checks in my game which is effectively what you want

I ended up using pawn sensing and some variables, changed most of my code basically. The issue now is the pawn sensing not following the camera. It moves horizontally, but not vertically. Do you happen to know if that’s something you can edit? If not I’ll try with this new code and the “was recently rendered” again

So because the pawn type is inherited, it doesn’t seem like you can attach it under a socket. I was unaware of this limitation originally. The method Auran mentioned would be better than both in this case, and the limitation with “Recently Rendered” is that it’s based on bounds of the object and you’d have to shrink those for it not to apply from behind the player when really close.