0
Answered

How to save GameObject when it Active or not?

GameBoy 2 weeks ago in Game Creator updated 3 days ago 4

1. The object of the game by default is FALSE, now I changed it to TRUE and save the game. But still loading is FALSE, it's not displayed correctly.
2. The object of the game by default is TRUE, now I changed it to FALSE and save the game. But the loading is still TRUE, it has not been properly hidden.

I just want to save GameObject in the Hierarchy no matter show or hide ,any Suggestions?

Unity version:
unity2018.4.11
Game Creator version:
1.04
Planned

Hi GameBoy.

This is currently not possible to do out of the box. We can't store references to the scene object and keep their state. There's a solution, however. When you enable/disable a game object, store a boolean Local Variable with the state of the object. You can use a "On Load Game" Trigger to set as active or inactive the game object based on the value of the variable.

Despite this, setting the enable/disabled state of an object is quite common. We're working to find an easy to implement solution that does this automatically.

Thank you for your reply. Before that, I tried to use bool variable (save), and tried many times, the results are as follows:

1. When the GameObject is changed from display to hide, debug is correct, but the game object is not hidden.

2. If you want to control the GameObject from display to hide through the button, you need to press the button twice to hide the game object.

For example ,click the button to display a image. The debugging is correct, but the display image needs to click the display button twice.

3.Even if the GameObject is hidden in the unity, but when you package, at first time the game is run and save, it will be hidden correctly. When I close the game and open and load it again , it will reappear.

I have done a lot of experiments because I think it is very basic to control the display and hiding of GameObject. If it's serious, this problem hasn't been solved , no matter how powerful GC is, it still can't make a game with saving function.

For example, in the game, it's impossible to unlock all the function buttons when the player is Lv1, right? In this case, Boolean values are needed to control the display of objects or hide other function buttons.

With this in mind, my plan to develop the game is out of the question.

This time, I hope you can improve the Boolean value saving function, because it doesn't seem to work. 


Thank you.

Answered

We've found an issue with our save/load system that we've already fixed. The thing is that when switching between scenes, if no game has been loaded and you try to load a previously saved game it will store the current state of the object on top of the loading you're trying to make.

This is a big issue that went completely off our radar, which might be what's causing you the problem.

On another note, we're going to be releasing with the next update the new "Remember" component. This component (or collection of components) will make it much easier to store common properties between play sessions.

For example, the Remember Transform component will remember and automatically teleport an object to its position, rotation and scale when the game was last saved. Same with the Remember Active component, which will make an object active, inactive or destroy it, depending on its last state.

We'll make an official announcement, but this should help you and speed up your workflow. Let us know how it goes or if you have any issues when the new Game Creator version comes.

+1

Wow, that's exciting news. The new version of GC is something to look forward to. If I encounter any related problems in the next version, I will continue to give you feedback. Thank you for your reply :-)