Serialization deserialization

Hi
I want to build in game a car from parts (engine, suspension, body - these are separate parts). The car has a physical simulation such as joints, rigidbody. I build the car in workshop, then i load it to game.

How can I serelize/deserelize a car from construction mode to game mode if the parts are separate blueprints?

1 Like

I would make a data table holding soft references to classes of the parts.
Then have a nested struct that would hold the information.

So it would have
Engine : => datatable row identifier for engine model
Suspension : => datatable row identifier for suspension model
etc

Inside of the parts of the blueprints make sure they have a reference to their data table counterpart , then just go through the car and get the datatable information for each included part and set it in the main cars struct which can be later saved for instance as a json file in a savegame.

To load pull out the json string describing the car, parse it into a struct and run a script that will spawn components based on the saved data table row descriptor.

“table holding soft references to classes of the parts” can you tell me more details, please?

Use soft references to classes to not load the class into memory before it is needed. Datatables are simplified database like structures in unreal. A car catalog part would be defined as a class that inherits if i remember correctly from datatablerow

Example

USTRUCT(Blueprintable)
struct FCarPartStruct : public FTableRowBase
{
// add part properties
}
This can be done in bp too just use a struct that inherits from TableRowBase

Then when creating a datatable choose your struct as the row / entry definition

The tsoftclassptr is the c++ version of a soft reference. In blueprints it’s the pink variant of a class. You will need to async load the soft class before you can spawn its full instance.

1 Like

Thanks for your answer

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.