Forum rules - please read before posting.

Saving Custom Script Variables

Hey all,

I've got everything working, except one thing! I have a custom script on objects that handles doors, if they're locked, if they're ever able to open etc. Simple boolean values.

When loading a saved game, these get set back to their defaults as they were when the scene initially loads.

Is there any easy way for me to remember the variables on a custom script?

My other idea was to go through and setup an AC "component variables" on each object, and a "remember variables" on that, and change the script I wrote to reference the component variable state.

If I need to do that, then I'm happy to go through and do it - was just hoping there might be something quicker :D

Thanks!

Comments

  • A guide to writing custom "Remember" components can be found here.

    As you're dealing with simple Bool values, though, relying on Variables / Remember Variables would be easier. To get/set a variable from a Variables component, use:

    var variables = GetComponent<Variables> ();
    var myVariable = variables.GetVariable ("MyBool");
    myVariable.BooleanValue = true;
    if (myVariable.BooleanValue) {}
    
  • Thanks, Chris!

    I got the custom Remember working ... then was having lock ups because I forgot not all objects are enabled at runtime.

    Have switched over to Variables/Remember Variables now instead and it's working perfectly. Thanks again for your help.

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.