using UnityEngine; using HutongGames.PlayMaker; public class PauseManager : MonoBehaviour { // define the FsmBool public FsmBool isPaused; void Update() { // check if the game is paused or not if (isPaused.Value) { // game is paused, perform paused logic } else { // game is unpaused, perform unpaused logic } } // function called when the pause button is clicked public void PauseButtonClicked() { // toggle the isPaused variable isPaused.Value = !isPaused.Value; } }
using UnityEngine; using HutongGames.PlayMaker; public class AnimationManager : MonoBehaviour { // define FsmBool's public FsmBool isIdle, isWalking, isRunning; Animator anim; void Start() { anim = GetComponentIn this example, we create three FsmBools named "isIdle," "isWalking," and "isRunning" to manage the states of an animation. We check the value of these FsmBools in the Update function to play the appropriate animation. We then create two functions, "WalkButtonClicked" and "RunButtonClicked," which set the appropriate FsmBools when called.(); // start in idle state isIdle.Value = true; } void Update() { // check which animation state should be active if (isIdle.Value) { // set the animator to play the idle animation anim.SetTrigger("Idle"); } else if (isWalking.Value) { // set the animator to play the walking animation anim.SetTrigger("Walk"); } else if (isRunning.Value) { // set the animator to play the running animation anim.SetTrigger("Run"); } } // function called when the walk button is clicked public void WalkButtonClicked() { // set FsmBools accordingly isIdle.Value = false; isWalking.Value = true; isRunning.Value = false; } // function called when the run button is clicked public void RunButtonClicked() { // set FsmBools accordingly isIdle.Value = false; isWalking.Value = false; isRunning.Value = true; } }