Saving an entity and assets created in gameplay

Hi,

In my application you start with a basic model and the functionality enables you to customise that model. I want to implement a save feature that allows the customised model to be saved. I was wondering if there was any feature in playcanvas to “save” an entity and associated assets? Is there a standard for saving an entity? (There must be, the editor does it!)

Cheers,
Matt

Save in the cloud/server or locally on the user’s PC?

Either. I want to generate a file that contains data on an entity and it’s children and associated assets that could either be saved locally or on a server that can be used to load that model at a later date.

In this particular case of a customiser, you would want to store the current state of customisation.

As a simple example, let’s say you had a choice of hats for a character. The hats would be identifiable from a hash, string, number, etc so all you would have to save is what hat was selected.

For saving locally, I just stored a JSON string into the localStorage that lists an identifiable number that the game can use to customise the character on load which looked something like this:

{"audioEnabled":true,"headPropIndex":1,"facePropIndex":1,"bodyPropIndex":1}

Javascript has built in JSON parsing and creation which helps as well.

1 Like