Search Unity

Is there better way to follow state machine flow than CustomEvents?

Discussion in 'Visual Scripting' started by JacobFast, Apr 18, 2022.

  1. JacobFast

    JacobFast

    Joined:
    Apr 29, 2014
    Posts:
    47
    So I have several states in chain and i want them executed in order one after another. When one state finish executing, the last node is TriggerCustomEvent, then in transition node between State1 and State2, I have CustomEvent listener that triggers StateTriggerTransition. See screenshots. Is there a better way to do that, seems like very hacky to me?
     

    Attached Files:

  2. Starpaq2

    Starpaq2

    Joined:
    Mar 14, 2013
    Posts:
    77
    Great Question.

    At this time I currently operate my transitions similarly. However, I have developed a personal methodology to prevent/reduce human error.

    Tips:
    • Name the transition node after the exact name of the custom event trigger within.
    • Avoid triggering a transition's custom event from outside the state graph its connected to.
    Example: If you want to transition the graph from a ui button click. That button should call a unity event trigger that calls a custom event from within the neighboring state graph to call the transition... (hopefully I explained well.)

    I have not confirmed if this effects performance but it helps myself keep custom events organized and reduces untraceable typos in custom events.

    Of course, I'm always on the lookout for improved workflows.