Processing inactive levels in background

I’m making a single-player space sim game where a player can jump from one solar system to another. I’d also like to simulate activities for all NPC ships in other solar systems in which the player is absent.

But if the game loads a level of the current solar system where the player exists, that means other levels will not be loaded, right? How would you recommend processing NPC ships in other solar systems in this case?

Off screen NPC’s would probably be needed to be processed by a manager. This could be simplified.

Ship A needs to travel to star system B so just get distance between A & B and vector lerp the travel distance with a constant speed.

This could even be done on a separate thread.

Once you load into the area closest to the ships travel distance load in the needed actor.

You can store essential data that should persist in objects that are separated from the Actors, like a UObject-derived “NpcEntity” class, which could hold values like health, money, current current location name, current target etc and are responsible for performing NPC-related actions, meaning it’s not the actors that do the decision making or hold the important values, but the NpcEntity objects.

In the GameInstance, you could add a NpcManager object, which is responsible for updating existing NpcEntity objects and creating NpcEntity objects whenever you want to spawn a new NPC.

When a map gets loaded, loop through the NpcEntity objects, find out which of them should become “active”, spawn their actors and link them up with the NpcEntity object and let the NpcEntity objects control the actors behavior.

When a map unloads, unlink the NpcEntity objects from the actors, let the actors get destroyed and let the NpcEntity objects continue doing their thing in an “unloaded” mode.

When a NpcEntity is in it’s “active” state with their actors spawned, you can let them do normal, complex actions, while if their location is “unloaded”/their actor is not spawned, you could have the actions be very simplified and abstracted.