On Perception Updated not updating on movement

When using On Perception Updated for AI controlling, it seems that the event does not fire when there is movement within the site of the AI, is that correct? Hence, if I already have triggered the event with an object, the same object will not trigger the event again when moving inside the vision of the AI?

I want an actor to follow my movement, so as far as I can see I have to put the target object (the player character in this case) into an array or something and call GetActorLocation on this for each tick in order to get the updated coordinate values? If I use the On Perception Updated it will not get the new coordinate values before I hit the “borders” of the AI’s vision.

Hope somebody understand what I mean.
Thanks for any help!

Thanks, that made it more clear! :slight_smile:

You pretty much get it. Perception updates when the perception state changes, which doesn’t include movement. You get the “in view” event and if you run far enough away from the AI then you should get another event when you go past the “out of view” distance. Between being able to see the enemy and not being able to see the enemy, tracking or anything else is up to you to handle.

You don’t need to do it on tick, though. You can put the AI logic on a timer that ticks off as slow as possible without making the AI stupid.

In the end this is a preferable way to do it since the perception system shouldn’t presume to know what you want to do when things are visible (or how often you want to do it). It’s pretty good compartmentalization IMO. Not the cleanest API but the AI system is very old and we’re stuck in a legacy situation. Hopefully we will get an alternative eventually.

No problem. Actually, the Behavior Tree system distributes the load of multiple AI across multiple frames. So using that to trigger your tracking logic (from a Service) is a pretty good option. That’s how I do it: perception adds/removes potential targets to/from an array and the BT Service calls the logic that tracks the best one.

If you’re using a BT then you might want to give that a try at some point.

1 Like