I have a building system that i work on it, at this time i work on Open/Close Doors, Widows and so on.
All object are builded by player and saved during playng game.
The problem i have i dont know how to save the Boolean IsDoorOpen? so it remember it initial building position, if door was open it will keep that position but it wont load the boolean IsDoorOpen? to know that door is already open so it need to close the door, instead it keep opening tru building.
I have SageGameObject, i already save all object that are spawned in world by player, but i dont know how to save boolean so Save and Load file know that the door was Open or Closed During Save or Loading
ti happen when door was open and game saved, if game will start again door will start from open position but if i try to close the door it will open again as you can see in CloseDoorAfterGameRestart print screen.
Notice you only ever need to make the save game if it doesnât exist. ONCE.
Youâre making a new one every time you save, which means everything gets overwritten.
You canât just write to the save game, you need to read it from disk update it and then write it back ( as in the pic ). Youâre only writing to it.
Each house needs to mange itâs own save game objects. If we take the example of âis the door open?â, it would be a bool in the save game. Initially itâs false, but when the player opens the door, the house needs to write that to the save game. Subsequently, when you play the game again, every house needs to read the save game and check if itâs own door is open. If it is, set the door open, otherwise leave it.
This means every house needs an id ( just an int ) because it needs to know which bool itâs supposed t use for the door.
You can keep these in an array, or you can have a âhouse save game structâ for each house.
Notice, you have to read the save game, update it, and write back out.
As far as I can tell youâre making a new save game each time, which will mean what was previously there will get overwritten.
Each house needs to control itâs own door bool in the save game. When the player opens the door, it should update the save game. When the game is restarted, each house needs to check itâs down door bool. If the bool is true, set the door to open, otherwise leave it closed.
This means each house needs an ID ( just an int ), so it knows which bool belongs to it.
Itâs ok to keep all the door bools in an array, each house can use itâs ID to read and write the correct bool. Another way is to have a âhouse save game structâ which includes the door bools and everything else conerned with the state of the house.
I have to test this basic save game, is way to different from i read about it, since i dont have that much experience mistakes are done.
I dont know if ID will work, every wall , floor frame are made by players so i keep them in an Array (i think), house is made from individual parts, like wall, floor, widows all created and set by player.
I just had the same problem with saving boolean values. I had a save game that stored a map data structure. Keys are enums and values are structs that contain a data table row handle and a boolean that indicates whether the âequipmentâ is equipped or not.
Right up until the moment of saving the boolean is the correct value but when I load/reload the save game the boolean would reset and be the wrong value. Everything else is loading correctly - the row name in the row handle (which is what I change to create a customization menu functionality), other variables in the save game etc.
I ended up using an enum for the equipped state, i.e. an enum with two keys of âEquippedâ and âUnequippedâ. This solved the issue and now everything loads correctly.
I really think this is a bug because I canât figure out why it just didnât work with booleans.