Forum rules - please read before posting.

Executing Actions only under certain conditions.

Hi Chris,

I have an actionlist with 3 action nodes. (Node01,Node02,Node3)

I would like to loop through the actionlist 4 times.
The first time, I would like to run all of the action nodes.
The second time, only run Node02 and Node03.
The third time, run Node01 and Node03.
The forth time, run all nodes.

Is it possible to do something like this?

Comments

  • The Variable: Run sequence Action can be used to run different subsequent Actions each time itself is run.

    For more complex logic: if you defined an Integer parameter in the Parameters tab to keep track of how many times you've run it, you could surround your Actions with ActionList: Check parameter Actions to determine which Action to run.

    Create a new Integer parameter named e.g. "Times run" and attach a simple script to it to increase this value by 1 each time it's run:

    using UnityEngine;
    using AC;
    
    public class ActionListRunCounter : MonoBehaviour
    {
    
        public string countParameter = "Times run";
    
        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.gameObject == this)
            {
                actionList.GetParameter (countParameter).intValue ++;
            }
        }
    
    }
    

    Then, insert an ActionList: Check parameter Action to check if the value is 1. If it is, reroute to your first "proper" Action. If not, reroute to another ActionList: Check parameter Action to check if the value is 2, and reroute that to either the second proper Action, etc.

  • Super awesome, thanks 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.