Disabling perception on "killed" NPCs

So I want to create an incapacitated state for my NPCs that I will later on expand to be either dead, paniced or incapacitated. But for now they are just dead when they become incapacitated.

But I want to disable their perception when they go into any of the incpacitated steps, and so far I haven’t managed. Right now the NPCs react to other NPCs around them, turning towards them while in the incapacitated state.

This is the current blueprint line I run to see if they have become incpacitated.
Notice that the “Detache from controller…” node isn’t attached. While it solves the problem with the turning, it also cuts off the NPC from its blackboard, causing a lot of other issues.

What other options do I have to turn off or limit the perception? I don’t really want to go into C++ as I have no idea how to do that.



You appear to have a logic error in removing null from your ActiveSquadMembers array. Surely that should be an Empty call instead?

Ah I need a Self reference there. Cheers!
But that wouldn’t fix the issue with the rotation though as it only removed the soldier from it’s squad.

Surely the behaviour tree is running the actual rotation behaviour though, right?

No the behavior tree only triggers when a Blackboard value has been changed. And that value is set when the AI controller runs an “On target perception updated (AIPerception)”

And I notice now that I don’t do a check on the perception update to see if “Self” is incapacitated. But that seem like a rather dirty fix to it as the perception tick would still run.

EDIT: Yes, adding a branch checking if “self” is incpacitated on the “On target perception updated (AIPerception)” solved the issue with the spinning corpses. But it doesn’t feel like the optimal solution.

Can you show the code for perception updated please?




It seems that OnPerceptionUpdated will be called when you deactivate your perception, which will run the code for rotation, correct?

Yes correct.
Having the “is incapacitated” check in the begining prevents the rotation though.

But the perception will continue to tick, not taking up a lot of performance but still an unessecary waste.

1 Like

If you have no other perception types, then why not just completely disable all perception and stop listening for any perception updates?

That’s what I’m trying to do here

But it doesn’t seem to work. And I haven’t found any other node to disable the perception with.

1 Like

That appears to be removing single senses however, not disabling all perception altogether

Correct.
But they shouldn’t have any other perceptions active as I’ve only activated sight and hearing in the AIPerception component.

In any case I haven’t found a way to disable the perception all together.

1 Like

I wonder if it’s holding on to dead actors, and if forcing their forget will do anything
image

No I don’t think so as it switches target as if it detects new people.

But got another bug where a force forget would be handy.

I couldn’t find the way either. So I have this workaround :sweat:

there is no way to stop the perception update

I think you should try not disabling the tick, just setting the sense as disabled and then calling RequestStimuliListenerUpdate

how do you do that? There is no way to disable in blueprints.

1 Like

The way you already do with SetSenseEnabled(false)

image
aa, but it tick does not work

There is no way to stop the perception update