Handling lots of little dudes when they're not in view

Every project I’ve ever made has been very modular with tiny scenes. I’m starting on a project now that is a little bit larger and will have persisten denizens all out doing their thing regardless of what the player is doing.

My question/curiosity is how this kind of thing is normally handled. I could have hundreds of these little guys (this isn’t including the “flavor” denizens like animals and such) all doing stuff that could affect the game, and I feel like having them always running, whether in view or not, could be bad.

Any thoughts on this? How do you guys handle non-static NPCs when they’re not in view, or nowhere near the player?

Here are the ideas I have now…

1: Just fake it. If an NPC gets too far away from the player disable them until the player comes back into view. Hopefully the player doesn’t realize that the denizen never moved.
2: Use some kind of coroutine system and significantly reduce they’re logic frequency the further they are from the player. This would still be faking it, but at least they would be active.
3: Let it run. Mess with performance later if it becomes an issue.

None of these seem ideal, and this is a whole new realm for me. Thanks in advance for any help. :slight_smile:

These are just a few thoughts, I don’t actually have experience making this kind of game.

It would take some serious time and effort, but I think the best solution would be to have all of the basic NPC functionality happen on a computer shader. For example, you could have NPC movement happen on the compute shader so you can have every NPC move each frame without slowing the CPU, then you could have the CPU go through and run simple checks to see if any more complex logic is required from the CPU (such as triggering animations or change in behavior).

An easier method would be having “LOD” logic, so there’s a simple logic that everyone always follows, and more complex logic when you can see an NPC. For example, if an NPC is supposed to pick up an item, you could simply add it to their inventory if they’re off-screen, but have them bend down and pick it up first if they’re on-screen.

While your shader idea seems like lunacy to me, the “LOD” logic idea seems like a great idea. I might actually start there while I wait for more ideas from others. Thanks!