Visual State Machine
  • Welcome
  • FAQ
  • Get Started
    • Setup
    • How to Create a State Machine
    • How to Open the Graph Editor
    • How to Create a State
    • About State IDs and Renaming States
    • How to Duplicate States
    • How to Set the Entry State
    • How to Create a Transition
    • About Transition IDs and Renaming Transitions
    • About Transition Labels
    • How to Trigger a Transition
    • How to Trigger a Transition by Label
    • How to Listen to Graph Events
  • Advanced
    • Execution Order
    • Listening to Events from Script
    • Writing Custom State Behaviours
    • Extending VSM
Powered by GitBook
On this page

Was this helpful?

  1. Get Started

How to Trigger a Transition by Label

You can also trigger a transition by the label you assigned to it. Labels do not need to be unique, which means that you can have multiple transitions with the same label. When triggering a transition by its label, the State Machine will trigger the first transition it finds, which has the given label and can be triggered from the currently active state. This behaviour ca be useful when you want to implement a return button for your UI or e.g. a restart option after the game is won or lost.

To trigger a transition by label you can simply call:

  • TriggerByLabel(string label)

  • TryTriggerByLabel(string label)

PreviousHow to Trigger a TransitionNextHow to Listen to Graph Events

Last updated 2 years ago

Was this helpful?