top of page
  • Writer's pictureJesse Toyota

Cutscene System

Our game has minimal cutscenes, with the beginning tutorial being the only real cutscene in the game. However, this cutscene had to be flexible, interactive, and cut into segments.

To achieve this, I created a cutscene system using Unity's Animator StateMachine. This may seem strange when Unity has tools for creating cutscenes, but using the Animator provided me with a visual state-based system. Rather than having specific camera work and animations, I needed the game to show skippable segments of dialogue and flexible camera positions.



I started by creating CutsceneState.cs and CutsceneStateBase.cs. The CutsceneState class would handle the individual states, while CutsceneStateBase provided a base class for other cutscene-related scripts. With these, I was able to create cutscene event scripts that I called CSE's. An example of these would be CSEMoveCharacter.cs, where I could input a character and position, and the state would handle the operations and timing before continuing. In order for a state to continue, all CSE's must be marked as complete. These can either be determined by duration or input.



Because Animator variables are limited, I created a CutsceneVariable class to get and set cutscene variables. This class has a string identifier and an object value. By creating a MonoBehaviour CutsceneController script and placing it on a GameObject, designers can use the controler to name and assign values from the scene. Because the Animator can access the CutsceneController, CSEs are then able to fetch and set values from the controller.




Pros

-Fast and and flexible to set up (depending on how the CSEs are structured) -Easy to make changes -Easy enough to visualize and understand flow of states -Can create multi-layered cutscene sequences using Layers -Script-based states allows for more potential and customization


Cons

-Rely on Animator's structure and transitions. -Sequences are visualized as states rather than segments/timelines. -Can be tedious to test


Conclusion

Using the Animator's StateMachine is a good way to setup and visualize the structure of cutscenes, but it can be harder to debug because it relies on Unity's StateMachine structure. This means that things such as transitions and animator variables must be considered.

In future projects, I would consider using the Animator as a way to layout and define data; but I would then create my own StateMachine controller to determine that that data is handled.

bottom of page