Forum rules - please read before posting.

Custom Actions that run cross frame

Hello, I 'd like to ask how to make custom actions run across several frames. I realized I cannot use coroutines in custom actions in the conventional way, how do I tell the custome action Run() funtion to wait and execute the next line in the next frame? Also, can I use iTween in custom actions?

Thank you.


  • In a case like this, it's typically best to just have an Action call a separate MonoBehaviour script function from where you can do whatever Coroutine / Update calls you want. You can even call such functions with the provided Object: Call event and Object: Send message Actions.

    From the Action's Run function, the float value returned is equal to the time that AC should wait before re-running the same Run function. See the default Run function and comments in the ActionTemplate file. "defaultPauseTime" is a special return value that will cause the Action to be re-run in the next frame.

  • Thanks, didn't realize the default Run function already addressed that.

    My use case is actually for a custom action that switches the Animator Controller for objects' Animator Components. It works well in the editor, but in some cases not executed in build. I think it is due to Unity imperfectness, and can actually be solved by introducing a short Engine:Wait before the switch animator action.

    So I plan to make the custom action to keep changing the Animator Controller until it is successfully changed. In previous trials, doing that in the same frame may still not work in rare cases. Thus I want to try to run this across frames to allow the small delay in Unity.

    Does it sound ok in Unity and AC logic? Or would there be more efficient ways to solve the "skipped action in build" issue?


  • I can't really comment if it's an issue with Unity, but your idea as a workaround sounds fine.

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.
Do NOT follow this link or you will be banned from the site!