RainWave Posted January 1, 2022 Share Posted January 1, 2022 so i started making a "open world"game in unigine and I would like to have a save and load system in my game but idk how to do that can someone help me? Link to comment
alexander Posted January 11, 2022 Share Posted January 11, 2022 Hi RainWave, > idk how to do that You need to serialize all of your major data to a file. Then load and deserialize from it. You can write, for example, these two methods as a base: // C# int money; float hp; vec3 player_position; quat player_rotation; void Save(string file_name) { File f = new File(file_name, "wb"); if (f.IsOpened) { // save player's info f.WriteFloat(hp); f.WriteInt(money); f.WriteVec3(player_position); f.WriteQuat(player_rotation); // save AI positions/states... // save environment objects (transformations)... // save ... } } void Load(string file_name) { File f = new File(file_name, "rb"); if (f.IsOpened) { // load player's info hp = f.ReadFloat(); money = f.ReadInt(); player_position = f.ReadVec3(); player_rotation = f.ReadQuat(); // load ... } } Best regards, Alexander. 2 Link to comment
Recommended Posts