We will entertain your mind, enhance your brain, expand your lifestyle.

State Machine

When creating the script to control the elevator, we investigated how to implement a state machine. There are three main ways to implement it in Unity:

  1. Using ‘StateMachineBehavior’
  2. Using add-ons
  3. Self Coding

1. is not possible because it is mainly based on the use of the Animation component and requires a class for each state, which seems difficult.

2. seems convenient as it comes with features such as an editor, but it is not possible because it is paid and the learning curve seems high.

For this reason, we decided to implement it using method 3. Referring to information from several sites, we created state branches at the start of the state (equivalent to Start()) and Update(), and then transitioned between states.

The elevator in Heptomusee state itself is not that complicated.

In addition to simple conditional transitions, we needed to implement transitions triggered by colliders and timers, but this turned out to be surprisingly easy. There are three state transitions from “CloseIDLE” (Open, Move, Exit), and we thought we might need a substate as a transition condition here, but we were able to handle this with conditional judgment within the state.