Improbable Icon

SpatialOS Forums

Procedural generation

So, as far as I know, from what I’ve read on schema, if I wanted to do procedural generation of maps using SpatialOS, I’d have to make a schema on the fly right? Or am I missing something? I looked into the schema generation tools, but apart from running the CLI, it doesn’t seem like there’s a way to do this. Maybe I’m missing something and someone could point it out, I’m 100% new to SpatialOS, and I’m trying to port my existing game to it, so pardon me if the answer is really obvious, I’m having trouble nailing this bit down

Hi @jarjarfinks

Schema can’t be generated or modified at runtime in the way I think you’re suggesting. They essentially form the building blocks of your SpatialOS entities so they need to all be pre-defined. That doesn’t mean you can’t use them for procedurally generated content though.

If you’re entirely new to SpatialOS I would recommend building a small test project to get to grips with everything before trying to port an existing project.

I assume you’re using one of the GDKs? Can I ask which engine you’re using?

Hey @JHerd,

I’ve been using SpatialOS about a month now, but the new direction of our project is to go procedural, and so I’m trying to find the “proper” way to account for new entities created if made on the fly. I’m using the Unreal GDK. The base project works fine, and making levels procedural does too, but I don’t think Spatial is taking note of the newly generated objects, so I’m trying to figure out how to do that at runtime

Right now I use “tiles” for procedural generation, that are small segments of the level, they are loaded on the fly and toggled on/off based on the map’s needs, making duplicated tiles as necessary. I’ve tried running the schema generation on each individual tile, on the main map, and nothing works. It just immediately crashes. So, I looked in the log and it complains about not having schema for it. The specific error message being:

 [2019.09.06-10.13.00:251][540]LogSpatialClassInfoManager: Error: Could not find class /Game/Maps/53x.Procedural01_C in schema database. Double-check whether replication is enabled for this class, the class is explicitly referenced from the starting scene and schema has been generated.
 [2019.09.06-10.13.00:251][540]LogSpatialClassInfoManager: Error: Disconnecting due to no generated schema for /Game/Maps/53x.Procedural01_C.

This error shows for each tile spawned. This error happened before and after generating schema for each individual tile in the list.

Hi @jarjarfinks

Can I ask what you mean by generating schema for each tile? The schema generation process covers everything in the project. You should only need to generate schema once each time after making build changes that might affect replication or RPCs.

If schema isn’t generating correctly for a given class then it may be a result of how that class is configured. Have you checked the replication settings for the classes as the error suggests?

Also, are all the classes throwing these errors in the Game/Maps/ folder?

@JHerd I am not using classes. I’m using a level blueprint to spawn maps. So each tile is a map. Then i set “Should Be Loaded” to true and spawn it on demand. Would it be better to make the tiles objects rather than small " maps"?

Hi @jarjarfinks

If I’m understanding correctly, you’re actually creating maps dynamically at runtime then? This would explain why you’re seeing schema errors as they wouldn’t have had schema generated for them in that scenario.

There’s a potential workaround to this if you could generate and save out the different tile maps in the editor and then generate the schema. This might be messy and/or time consuming though and somewhat defeats the point of procedural generation in my opinion.

A better solution would probably be to make the tiles objects instead though, as you suggest