PlayerStateBehaviour
A base state class for defining modular player behaviors within the Fusion FSM framework. This class integrates closely with Animancer and KCC to provide runtime animation control, input gating, and flexible state logic.
public class PlayerStateBehaviour : StateBehaviour<PlayerStateBehaviour>
🔌 Injected References
KCC Controller– Controls the player's physics and movement.PlayerActor Player– The owning player actor.ActorVisualController VisualController– Used to control visuals and animations.
These fields are auto-filled at runtime by the orchestrating state machine.
🧠 State Identity
string stateKey
Used to identify this state within the PlayerBehaviourMachine.
👐 Hands & Input Affects
Hands affectsHands
Type: [Flags] enum
Options: NONE, LEFT, RIGHT
Indicates which hand(s) this state affects.
AffectButtons affectsButtons
Type: [Flags] enum
Options: NONE, G, M
Represents buttons gated/used by this state.
🎬 Animation Integration
Most animations are applied via the VisualController, with various overloads for precise control.
Animation Playback Helpers
ApplyToAnimancers(int layer, ClipTransition, crossFade, fromStart, playbackSpeed, loopState, isAdditive, mask)ApplyToAnimancers(int layer, MixerTransition2D, crossFade, machineTime)ApplyToAnimancers(int layer, FadeTo goal)StopAnimancers(int layer)ApplyToAnimancers(int layer, float weight)ApplyToAnimancers(int layer, AvatarMask mask)
These methods play or modify animations on the appropriate animancer layer, often using AnimancerState lists.
🎮 Movement Speed Properties
walkSpeed: 4fsprintSpeed: 5.4f
Useful for states like walking, running, or dashing.
🧩 Overridable Hooks
NotifyOfData(NetworkBehaviour[] anyData): Called when shared data is passed into the state on activation.AnimatorIK(int layerIndex): For handling animator IK logic in derived classes.
🔁 FSM Metadata
_BaseLayer: Reserved base layer index for general use._HandsLayer: Reserved layer index for hand-specific animations.
👋 HandStateBehaviour (Subclass)
public class HandStateBehaviour : PlayerStateBehaviour
A thin subclass that distinguishes between main and secondary state machines (e.g., main body vs. hand gestures). Inherits all logic from PlayerStateBehaviour.