Forum rules - please read before posting.

How can I transform component variable to int to set interaction parameter?

I set an int parameter in an ActionList, and there is also an int Component variable in the Variable Component.How can I transform the int component variable to int to set interaction parameter of the actionlist?


  • Welcome to the community, @FromZero.

    The ActionList: Set parameter Action can be used to set an Integer parameter from a Variable - but currently this must a Global Variable.

    To get around this, create an Global Integer Variable named e.g. "Temporary Int", and use the Variable: Copy Action, before ActionList: Set parameter, to transfer the Component Integer's Variable to "Temporary int" so that this can be used to set the parameter.

    Alternatively, it's also possible to update the parameter directly through scripting:

    using UnityEngine;
    using AC;
    public class SetIntFromComponentVar : MonoBehaviour
        public ActionList myActionList;
        public Variables variables;
        public string variableName;
        public string parameterName;
        private void OnEnable () { EventManager.OnBeginActionList += OnBeginActionList; }
        private void OnDisable () { EventManager.OnBeginActionList -= OnBeginActionList; }
        private void OnBeginActionList (ActionList actionList, ActionListAsset actionListAsset, int startingIndex, bool isSkipping)
            if (actionList == myActionList)
                int componentIntValue = variables.GetVariable (variableName).IntegerValue;
                actionList.GetParameter (parameterName).intValue = componentIntValue;

    This script hooks into the OnBeginActionList custom event to transfer the Integer value when the ActionList is run. For details, see the Manual's "Custom events", "Variable scripting" and "ActionList scripting" chapters.

  • it works,thanks a lot! ;)

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.