Forum rules - please read before posting.

Generating and executing an action list from inside an action

Hi!
I have been generating action lists through script which has worked fine so far, but now I'm trying to generate and execute a list generated inside of a custom action. This doesn't seem to work since Action isn't a MonoBehaviour.

Any ideas on how to dynamically create and execute actions inside the Run method of an action?
Thanks!

Comments

  • Generally speaking, if you need a MonoBehaviour's feature set to work with an Action, you have the Action expose a reference to that MonoBehaviour and then run a function from within. Or just use e.g. the Object: Call event Action.

    That said, Why does the Action not being a MonoBehaviour prevent you from generating a list? If you can share the actual code you're trying to run, I'll better understand the issue.

  • edited March 2020
    Thanks for the quick reply!

    I'm trying to create a custom Action class that in its Run method dynamically adds a number of actions and returns 0 once all the actions are executed.
    The reason I'm not calling another ActionList from within the Run method is because the numbers of actions (and their order) should vary depending on other variables.

    I don't need a MonoBehavior per se, I tried just newing up an instance of the ActionList class and add the actions in the correct order, but I get a runtime exception when I call the Interact method on the ActionList because it tries to reference the GameObject.
  • I'd say it'd be best to only generate the Actions at runtime - not the ActionList itself.

    Consider creating a "blank" ActionList that you can reference with e.g. an ActionList: Run Action. You could then use that to run the ActionList, and use a custom Action before it to generate the Actions themselves.

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.