viewers access
public void SwitchState<StateType T>(ContextType context)
CyberPsychosis > StateMachine > SwitchState
Change the state of a statemachine, changes the value returned when getting the current state.
using CyberPsychosis;
using UnityEngine;
// Create a player class
public class Player : MonoBehaviour
{
// Create a new statemachine for MovementState, inherited from State<Player>
StateMachine<MovementState, Player> _movement = new StateMachine<MovementState, Player>();
private void Start()
{
// Switch to the default movement state
_movement.SwitchState<DefaultMovementState>(this);
}
}
| Type | Name | Description |
|---|---|---|
<StateType> |
T | The type of the new state |
<ContextType> |
context | The context send through to the new state |