Advice on Refactoring AI Patrol System for Better Performance and Scalability

Hey everyone,

I’m working on an AI patrol system where the AI moves between patrol points, and each point triggers specific actions like playing animations, waiting, or turning. The system works fine right now, but I’m starting to think it could be a lot more efficient and scalable.

At the moment, each action (like playing an animation or waiting) is its own actor. The AI reaches a patrol point, the patrol route checks what actions need to happen, and it broadcasts those actions to the AI. The AI then performs the action and signals when it’s done. It feels a bit clunky to have each action as a separate actor, and I’m worried this will lead to performance issues as I scale up with more patrol points and actions.

I’m also finding it inconvenient to manage, as I add more actions, I can already see the system becoming harder to maintain with tons of small blueprints cluttering everything.

Has anyone done something similar or have suggestions for a cleaner, more scalable way to handle this? Any thoughts would be appreciated!

Thanks

Level:

Current hierarchy:

11 bit studios had a talk not long ago about more complex ai behavior including partrol paths.

Might be worth a look:

1 Like

Thanks, I’ll check it after work! ^^

Hi, I apologize for the delay. I watched the video, but I found it a bit vague and didn’t understand much. From what I gathered, it seemed like overkill for what I was looking for.

Afterward, I discovered this guy who explained how to approach it using state trees. I then reworked that idea to incorporate it into a behavior tree.

What I’m currently doing is creating an actor called BP_PatrolRoute, which contains a list of child BP_PatrolPoints. Each patrol point has a list of previous and next points to keep track of its neighbors, along with a list of actions to take at that point (I’ll explain that later).

The behavior tree consists of a selector that includes all the tasks the AI can perform at each point (for example, play an animation, proceed to the next point, or wait). Thanks to the service in the selector, it updates the current action at the current point and selects the appropriate task to execute.

image

I have enough flexibility using this approach without needing an actor for each action. I’m not certain if this is the correct method, and I’m still working on it, but it feels robust to me—though I could be wrong. :blush: