How To: Save Only Character Data

Announcements, support questions, and discussion for Save System for Opsive Character Controllers.
Post Reply
User avatar
Tony Li
Posts: 22200
Joined: Thu Jul 18, 2013 1:27 pm

How To: Save Only Character Data

Post by Tony Li »

This post explains how to use the Save System to save only character data (Opsive UCC in this example) and not the current scene or data about other objects.

To save only the Opsive player state and position:

1. Set up a Save System GameObject with these components: SaveSystem, JsonDataSerializer, and PlayerPrefsSavedGameDataStorer.
  • Options: You can use BinaryDataSerializer or your own DataSerializer subclass instead of JsonDataSerializer, and DiskSavedGameDataStorer or your own SavedGameDataStorer subclass instead of PlayerPrefsSavedGameDataStorer. The saved game data storer won't be used; it just silences a warning from the Save System about not having a SavedGameDataStorer.
2. On the SaveSystem component, untick Save Current Scene. This will prevent the Save System from recording which scene is current active and then reloading that scene when restoring saved data.

3. Add a UCCSaver component to the player. Tick the options you want to save. Do not add any other saver components to any other GameObjects unless you want the Save System to save their info, too.

4. To save the player's data to a string:

Code: Select all

using PixelCrushers;
...
string s = SaveSystem.Serialize(SaveSystem.RecordSavedGameData());
You can then store this string however you want.

5. To restore the player's data:

Code: Select all

SaveSystem.ApplySavedGameData(SaveSystem.Deserialize<SavedGameData>(s));
Post Reply