using CoinFlipGames.FSM;
using System;
using UnityEngine;
public class MyMonoBehaviour : MonoBehaviour
{
// Set in the inspector!
public StateMachine stateMachine;
private enum States
{
Start,
Player1Turn,
Player2Turn,
Player1Win,
Player2Win
}
void Start ()
{
// First state becomes the default and runs automatically
stateMachine.AddState(
States.Start,
(previous) => { Debug.Log ("Start.OnEnter"); }, // Can use lambda functions
() => { Debug.Log ("Start.OnUpdate"); },
(next) => { Debug.Log ("Start.OnExit"); }
);
stateMachine.AddState(
States.Player1Turn,
this.StartPlayer1Turn, // Or plain functions as long as they match Action<Enum>
...
);
}
private void StartPlayer1Turn (Enum previous)
{
Debug.Log ("Player1Turn.OnEnter");
}
}
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Simple Finite State Machine for Unity3D
License
MIT, Unknown licenses found
Licenses found
MIT
LICENSE
Unknown
LICENSE.meta
coinflipgamesllc/fsm
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Simple Finite State Machine for Unity3D
Resources
License
MIT, Unknown licenses found
Licenses found
MIT
LICENSE
Unknown
LICENSE.meta
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published