Predicted State Machine
Scene setup
Minimal Example
// A state without input
public class IdleState : PredictedStateNode<MyState>
{
public override void Enter() { /* start idle anim */ }
protected override void StateSimulate(ref MyState s, float dt) { /* no-op */ }
}
// A state with input
public class MoveState : PredictedStateNode<MyInput, MyState>
{
protected override void StateSimulate(in MyInput i, ref MyState s, float dt)
{ s.velocity = new Vector3(i.x, 0, i.y) * s.speed; }
}
// Somewhere in a predicted identity or node
void HandleTransitions()
{
if (/* want next */) machine.Next();
if (/* want specific */) machine.SetState(mySpecificNode);
}Last updated