Forum rules - please read before posting.

How to save Variables?

Hello. I'm stuck now about saving Variables. I know using Remember Variables for saving variables so I added it to the sprite component, but I don't know what should I do next.

https://imgur.com/undefined

First, the component variables of Variables (Script) is empty, even though I've already created 1 Integer variable and 2 Boolean variables in Variable manager under AC game editor.
Next, I created the Variables in Scene manager under AC game editor and I added 1 Integer variable to it, but still empty, I completely don't know what should I do for saving those variables.

Unity version: 2019.1.14f1
AC version: 1.69.2

Thanks!!

Comments

  • Both Local and Global Variables are saved automatically. Component Variables require the Remember Variable script.

    The component variable is it's own thing, separate from Global and Local in the Game Editor Tab.

  • Yes, Global, Local and Component are all different places to define variables.

    From the Manual's "Variables overview" chapter:

    Global, Local or Component? To avoid clutter, a variable should be placed according to where it need to be accessed. If it must be accessed across multiple scenes, it should be Global. If it is only accessed within a single scene, it's best o as Local. Component variables are best relied on when they are associated with the GameObject or Prefab they are attached to - for example, an "Is locked?" variable placed on a treasure chest.

    As you've already defined the Variable in the Variables Manager, it'll either be a Global or Local (depending on which tab you had selected at the time). This will be saved automatically. In order to change or read its value at runtime, use the Variable: Check and Variable: Set Actions respectively, setting the Source field to where you defined it.

  • Hello, Deckard_89 and Chris! Thanks for the comments.

    Both Local and Global Variables are saved automatically. Component Variables require the Remember Variable script.

    I didn't know about those are saved automatically... I saw trough the manual and relative posts here though, probably I overlooked it.

    Actually, I was thinking more difficult too much. I added Constant ID and Remember Transform to each hotspots, then finally it completely worked! (Or, I should add only Remember Transform in this case.)

    I don't know why it didn't be saved. In my opinion, one of the reasons was that I chose Remove as a method to disappear items from the play screen. Originally, I should have chosen "Teleport" like the 2D tutorial, but I was choosing Remove.

  • In a nutshell, I was completely misunderstanding and I didn't know how different Variables and Remember components.
    Thanks to Deckard_89 and Chris. :)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.