Saving Boolean issue

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.

You need to use a save game object:

1 Like

on your second screenshot, drag a pin from save game ref and use the “Save Game to Slot” node

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

alt text

I have Save and Load game setup like this.

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.

328802-

There’s a number of things that don’t look right, or are missing I think.

  1. Here’s the basic save game setup:

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.

  1. 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.

  2. 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.

Does that make sense?

I dont see anything wrong from the screenshots. You will have to watch a tutorial on ue4 debugging and try to figure out what is the problem

it should work based off the screenshots.

You will have to learn how to debug, it takes a lot of work.

Another option would be to find a tutorial for saving/loading and follow along

There’s a number of things missing or wrong, I think.

Here’s the basic save game setup:

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.

Hope that makes some sense.

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.

Yes, each house needs to know where it’s data is in the save game. That means using IDs.

I’ll give you an example if you get stuck…

Itd love to know more about this if you do have an example.

Im really struggling to save booleans. Eg. In settings Click mph or kmh. It wont save my choice.

Im really struggling for any guides or reference material on saving booleans.

In my example code above, just change the int for a boolean. They all work the same way.

If you want a specific example, can you tell me where the bool is, that you’re trying to save?

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.

1 Like