Ideas, Designs, and Architectural Implementations for Managing Spatial Relations of Many Objects

Let’s say I have a many game objects who inquire their environment once or twice a second. They categorize nearby game objects into groups, which are later used to drive aspects of intelligence. The environment has a high count of game objects.

Naturally, a developer’s inclination is to pop off Physics.OverlapSphere(s), implement layer masks, feed a handful of lists / arrays, and hope for the best. Simple? Yes. Performant? Exponentially not. Want field-of-view or line-of-sight checks? Bask in frames per minute.

What are some designs for efficiently managing and querying spatial relations for highly populated, volatile data?

Spatial subdivision is the most obvious one and one that is commonly used in games.

Another way is to only update the actors closest to the player or the camera, i.e., fake it. Most users don’t care what’s happening outside of their field of view.

Honestly though, I’d just try it out naively first, see if you really do have a performance problem.

1 Like