01 Game Manager

Difficulty: Intermediate - Recommended after Golf Events

Location: Assets/Plugins/Animancer/Examples/06 State Machines/01 Game Manager

Namespace: Animancer.Examples.StateMachines.GameManager

This example demonstrates how you can implement a simple enum-based system for managing the state of a game and then how you can use Animancer's Finite State Machine system to achieve the same result. In general, enum-based systems are easy to use for simple tasks while proper FSM systems require more initial effort to set up but are much easier to maintain and expand, which is important for more complex scenarios.

The "game" consists of several states:

State Description
Introduction The camera orbits around the character. When the player clicks the mouse, go to Ready.
Ready The camera moves behind the character and put them into a pose ready to hit the ball. When the player clicks the mouse, go to Action.
Action The camera looks towards the ball as the character swings and hits it using the GolfHitControllerAnimancerHybrid script from the Golf Events example. When the swing is complete and the ball stops moving, go to Fade Out.
Fade Out The screen gradually darkens. When it becomes fully black, go to Fade In.
Fade In The camera and character reset to the Ready positions while the screen is still black, then it fades back in. When it has fully faded in, go to Ready.

As the first State Machines example, the explanations of each implementation go into quite a bit of detail so they are separated onto their own pages:

Enum The enum-based Game Manager implementation.
FSM The same mechanics implemented using Animancer's Finite Staate Machine system.
Comparison An overview of the advantages and disadvantages of each approach.