Forum rules - please read before posting.

onvariablechange how to

Hello everyone

is the onvariablechange an equivalent of update in unity?
lets say the variable talkedto from false become true after the conversation , how would i use the onvariablechange cutscene? thank you , i checked around but didn't get it

Comments

  • The "On variable change" cutscene field in the Scene Manager is called whenever you re-enter gameplay, if a variable was changed while gameplay was blocked.

    It's not dependent on any particular variable, so your Actions would have to just be a blanket check for any specific variable you want to detect, i.e. "Variable: Check" -> "TalkedTo".

    If you want to listen out for a specific variable being updated, you can hook a custom script into the OnVariableChange custom event:

    using UnityEngine;
    using AC;
    
    public class VariableEventExample : MonoBehaviour
    {
    
        public string variableName = "talkedto";
        public ActionListAsset actionListOnTrue;
    
        private void OnEnable () { EventManager.OnVariableChange += OnVariableChange; }
        private void OnDisable () { EventManager.OnVariableChange -= OnVariableChange; }
    
        private void OnVariableChange (GVar variable)
        {
            if (variable.label == variableName && variable.BooleanValue)
            {
                Debug.Log ("Variable " + variable.label + " was set to true");
                actionListOnTrue.Interact ();
            }
        }
    }
    
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.