Banner Image

Unit Manager

An efficient system for handling complex game AI in Unreal Engine 5

Technologies Used

Problem: Unreal Engine’s AI and Movement Components Are Expensive

Unreal Engine’s default character and movement components are designed for high-quality player interactions, but they come with a high computational cost. In our case, the system could only handle about 10 characters simultaneously on low end devices. This was a significant limitation, as our game wanted to support 100+ AI enemies interacting in real-time.

Solution: Custom Unit Manager

To address this, we developed a custom Unit Manager designed to efficiently handle a large number of AI entities. By optimizing how AI behavior is managed and offloading expensive calculations, we vastly increased the system’s capacity, allowing the game to manage over 100 AI enemies at once with minimal impact on performance.

Multithreading and Tick Aggregation

Optimizations include:

Avoidance Algorithm

  • Problem: The cost of Avoidance is n^2 as all units must avoid eachother
  • To optimize this we used a 3D array "grid" to partition the units into smaller groups based on their location
  • Each index in the 3D array represents a world location range, to convert the unit location to a grid cell we divide their location by the cell size
  • Units only avoid other units in the same grid cell, greatly reducing the exponential cost of avoidance
  • Avoidance Gif
    Back to Portfolio