AI performance

You are probably deep diving into a complex project, but I like that.
We don’t have a lot of info to work with but I can give some tips based on what I see here.

I am pretty sure you are using Tick to check for certain conditions or to update conditions per frame. This is not recommended like the others said already. Instead you should take a look at how delegates / event dispatchers work.
What I mean by this is that there is a way to subscribe an object to another object to be notified when it does something, without having to check for it manually:

Another thing, you should reduce the amount of calculations needed where possible, especially if they run on tick. For Example, you can easily divide an RTS game into classes which manage the units for each team:

RTSTeamSubsystem:
  - Holds teams of players and AIs playing the RTS

Team:
  - List of its own units
  - Holds all UnitSquads for this team
  - Access to team logic

UnitSquad:
  - Holds units  within this squad (think of a commander, commanding tanks)
  - Reacts to player commands and triggers.
  - Acts as the main AI behind a set of units.
  - Does formation and navigation logic, to avoid calculating this per unit.

Unit:
  - Mindless Pawn controlled by its UnitSquad (like a hive mind), to avoid extra calculations.
  - Simplified collision, optionally ignoring its own squad's collision or any Unit's collision.
  - Does not execute its own AI?

3 Likes