Summary
A simple system that can
Animancer.FSM.StateMachine`1.InputBuffer`1.Buffer(`0,System.Single)
a state then try to enter it every time
Animancer.FSM.StateMachine`1.InputBuffer`1.Update(System.Single)
is called until the Animancer.FSM.StateMachine`1.InputBuffer`1.TimeOut
expires.
- Assembly
- Animancer
.dll - Namespace
- Animancer
.FSM - Base Types
-
- Object
- Derived Types
graph BT
Type-->Base0["Object"]
Type["StateMachine<TState>.InputBuffer<TStateMachine>"]
class Type type-node
Derived0["StateMachine<TState>.InputBuffer"]-->Type
click Derived0 "/animancer/api/Animancer.FSM/InputBuffer"
Derived1["StateMachine<TKey, TState>.InputBuffer"]-->Type
click Derived1 "/animancer/api/Animancer.FSM/InputBuffer"
Syntax
public class StateMachine<TState>.InputBuffer<TStateMachine>
where TStateMachine : StateMachine<TState>
Remarks
Documentation:
Input Buffers
Example:
public StateMachine<CharacterState> stateMachine;// Initialized elsewhere.
[SerializeField] private CharacterState _Attack;
[SerializeField] private float _AttackInputTimeOut = 0.5f;
private StateMachine<CharacterState>.InputBuffer _InputBuffer;
private void Awake()
{
// Initialize the buffer.
_InputBuffer = new StateMachine<CharacterState>.InputBuffer(stateMachine);
}
private void Update()
{
// When input is detected, buffer the desired state.
if (Input.GetButtonDown("Fire1"))// Left Click by default.
{
_InputBuffer.Buffer(_Attack, _AttackInputTimeOut);
}
// At the end of the frame, Update the buffer so it tries to enter the buffered state.
// After the time out, it will clear itself so Update does nothing until something else is buffered.
_InputBuffer.Update();
}
Type Parameters
Name | Description |
---|---|
TStateMachine |
Constructors
Name | Summary |
---|---|
InputBuffer |
Creates a new Animancer.FSM.StateMachine`1.InputBuffer`1 . |
InputBuffer |
Creates a new Animancer.FSM.StateMachine`1.InputBuffer`1 for the specified `stateMachine`. |
Properties
Name | Value | Summary |
---|---|---|
IsActive | bool |
Is this buffer currently trying to enter a
Animancer.FSM.StateMachine`1.InputBuffer`1.State ? |
State | TState |
The TState this buffer is currently attempting to enter.
|
StateMachine | TStateMachine |
The
Animancer.FSM.StateMachine`1 this buffer is feeding input to. |
TimeOut | float |
The amount of time left before the
Animancer.FSM.StateMachine`1.InputBuffer`1.State is cleared. |
Methods
Name | Value | Summary |
---|---|---|
Buffer |
void |
Sets the
Animancer.FSM.StateMachine`1.InputBuffer`1.State and Animancer.FSM.StateMachine`1.InputBuffer`1.TimeOut . |
Clear |
void |
Clears this buffer so it stops trying to enter the
Animancer.FSM.StateMachine`1.InputBuffer`1.State . |
TryEnterState |
bool |
Attempts to enter the
Animancer.FSM.StateMachine`1.InputBuffer`1.State and returns true if successful. |
Try |
void |
Calls
Animancer.FSM.StateMachine`1.InputBuffer`1.TryEnterState . If it fails, then Animancer.FSM.StateMachine`1.WithDefault.ForceSetDefaultState .
|
Update |
bool |
Calls
Animancer.FSM.StateMachine`1.InputBuffer`1.Update(System.Single) using UnityEngine.Time.deltaTime . |
Update |
bool |
Attempts to enter the
Animancer.FSM.StateMachine`1.InputBuffer`1.State if there is one and returns true if successful. Otherwise the
Animancer.FSM.StateMachine`1.InputBuffer`1.TimeOut is decreased by `deltaTime` and Animancer.FSM.StateMachine`1.InputBuffer`1.Clear is called if it reaches 0.
|