Forum rules - please read before posting.

Link To for local variables

Hi

Is there a way to Link To a custom script for local variables?

Currently I'm monitoring local variables in the Update() function of scripts, which is fine, but it feels inefficient and it would be nice to have my script told when a local variable changes. This works for Global Variables via the Link To custom field option. Is something similar available for Local Variables?

Olly

Comments

  • Hi Olly,
    Local Variables can be retrieved using the below.

    GVar myVar = LocalVariables.GetVariable (int id);
    GVar myVar = LocalVariables.GetVariable (string name)

    and the values can be read and set by using the below script.

    myVar.IntegerValue = 2;
    myVar.BooleanValue = true;
    myVar.FloatValue = 3.5f;
    myVar.TextValue = "Hello";
    myVar.Vector3Value = new Vector3 (1f, 2f, 3f);

    https://adventurecreator.org/files/Manual.pdf
    I found this info on page 276 of the manual. There is a portion on Variable scripting.
    Hope this helps.

  • Thanks. Yes, already using that. The query was whether there is a delegate or Link To option for local variables. There seems to be for Global Variables, but it seems odd that Local ones don't have something similar, that way the script could be told when a variable changes rather than checking every frame in Update().

  • They cannot, but Component Variables - which I'd recommend over Local as they offer a mix of the advantages of both Local and Component - can.

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.