Download

AI Perception Sight Sense. What does SuccessfullySensed mean ?

I have a cover-based shooter game and am trying to use the Sight Sense to control whether the NPCs shoot at each other or not.

I am testing with 3 NPCs in “simulate” mode in the editor. 2 NPCs are one team, and a single Enemy NPC on the other.

  • When I start “simulate” in the editor, all the NPCs get perceptionupdated notification with WasSuccessfullySensed() set to true. This is used as a signal to start shooting at the other team.

  • When the Enemy NPC ducks into cover, the other two NPCs get a perceptionupdated notification with WasSuccessfullySensed() set to false. This makes the opposing team stop shooting.

  • When the Enemy NPC comes out of cover, only one of the other NPCs gets a perceptionupdated notification at all. So only one NPC keeps taking shots.

Turning on the AI debugger (which I could not get to work in simulate mode) doesn’t help much. I can see the Sight Sense lifetime reset to 0 every time the enemy NPC pops up, but I never get the notifications.

This brings up a basic question as to whether using the WasSuccessfullySensed() function the correct way to toggle on and off behavior controlled by what a Character can see ? Or is there another way I’m supposed to use the Sight Sense ?

bumpitybump

Currently fiddling around using AIPerception myself.

OnTargetPerceptionUpdated

  • does not fire when the MaxAge of the perception expires.
  • The lifetime will always be zero.
  • WasSuccessfullySensed has always returned True/False properly for me.

HandleExpiredStimulus()

  • called when the perception expires
  • does not include the actor it expires on

I made an engine change to fire off an event with the same signature of OnTargetPerceptionUpdated for when the lifetime expires.

Make sure your PeripheralVisionAngleDegrees is wide enough for your liking.

You can watch the NPC’s perception setup by pressing “’” (apostrophe) and then pressing “5” on the numeric keypad. This will show you the SightRadius, LoseSightRadius and the PeripheralVisionAngleDegrees being used. Make sure you are facing the NPCs you want to debug. You may have to toggle the apostrophe key a few times to get the one you want.

When I look at the perception in the debug view, there are green spheres over the “Sighted” targets, even after I’ve received a false in WasSuccessfullySensed for those targets.

I have feeling that it might have something to do with the location of the target, since my NPCs are bobbing in and out of cover in the same place. There is a flag (I forget the name) that makes the system report perception even if the location hasn’t changed, but in that case it seems to ignore the line of sight. NPCs in cover will still sense as “seen”.

Thanks for the tips. I think I’ll have to debug the engine code myself as well.