Improbable Icon

Preloading Persistent Entities

unity
v12-0-4

#1

Heya All -

As I continue to make progress on my game, I’ve been trying to figure some things out around the Custom Entity Pipelines; specifically what I’d like to do is to ensure that all “persistent” entities in the area of interest when I spawn my player are rendered prior to spawning my player (and any other non persistent entities in the AoI) Additionally, it would be incredibly useful if I could fire an event when all persistent entities are rendered, before it begins spawning the non-persistent entities in the scene; so that I could use a loading screen to make for a nicer and smoother experience when the player first spawns (all static/persistent content will already be rendered behind the UI)

Has anyone experimented with something / anything like this? This really is only for when you first enter the game, as presumably I should be able to set my workers Area of Interest wide enough that things like terrain tiles and other entities that rely on that will be rendered by the time I reach them.


#3

There’s a way to pre-load gameobject easily that I learned recently.

Here’s my client connection code as an example.

void Start()
{
SpatialOS.AssetsToPrecache = new List()
{
“Star_Base”,
“Fleet”,
“Asteroid1”,
“Asteroid2”,
“Asteroid3”,
“Asteroid4”,
“Asteroid6”,
“Drone_Carrier”,
“Dreadnought”,
“Battlecruiser”,
“Missile_Frigate”,
“Assault_Frigate”,
“Flak_Frigate”,
“Defender”,
“Interceptor”,
“Bomber”
};

        SpatialOS.AssetsToPrePool = new Dictionary<string, int>()
        {
            { "Star_Base", 2 },
            { "Fleet", 2 },
            { "Asteroid1", 100 },
            { "Asteroid2", 100 },
            { "Asteroid3", 100 },
            { "Asteroid4", 100 },
            { "Asteroid6", 100 },
            { "Drone_Carrier", 1 },
            { "Dreadnought", 1 },
            { "Battlecruiser", 1 },
            { "Missile_Frigate", 1 },
            { "Assault_Frigate", 1 },
            { "Flak_Frigate", 1 },
            { "Defender", 1 },
            { "Interceptor", 1 },
            { "Bomber", 1 }
        };

        SpatialOS.ApplyConfiguration(Configuration);

        SpatialOS.OnConnected += OnConnected;
        SpatialOS.OnDisconnected += OnDisconnected;

        Application.targetFrameRate = -1;
        Time.fixedDeltaTime = 1.0f / fixedFramerate;

        SpatialOS.Connect(gameObject);

}