CharacterState Class

Summary

Base class for the various states a Brains.Character can be in and actions they can perform.
graph BT Type-->Base0["StateBehaviour"] click Base0 "/animancer/api/Animancer.FSM/StateBehaviour" Base0-->Base1["MonoBehaviour"] Type-.->Interface0["IOwnedState<CharacterState>"] Type-.->Interface1["IState"] click Interface1 "/animancer/api/Animancer.FSM/IState" Type["CharacterState"] class Type type-node Derived0["RespawnState"]-->Type click Derived0 "/animancer/api/Animancer.Examples.AnimatorControllers.GameKit/RespawnState" Derived1["LocomotionState"]-->Type click Derived1 "/animancer/api/Animancer.Examples.AnimatorControllers.GameKit/LocomotionState" Derived2["DieState"]-->Type click Derived2 "/animancer/api/Animancer.Examples.AnimatorControllers.GameKit/DieState" Derived3["AirborneState"]-->Type click Derived3 "/animancer/api/Animancer.Examples.AnimatorControllers.GameKit/AirborneState" Derived4["IdleState"]-->Type click Derived4 "/animancer/api/Animancer.Examples.AnimatorControllers.GameKit/IdleState" Derived5["FlinchState"]-->Type click Derived5 "/animancer/api/Animancer.Examples.AnimatorControllers.GameKit/FlinchState" Derived6["LandingState"]-->Type click Derived6 "/animancer/api/Animancer.Examples.AnimatorControllers.GameKit/LandingState" Derived7["AttackState"]-->Type click Derived7 "/animancer/api/Animancer.Examples.AnimatorControllers.GameKit/AttackState"

Syntax

[AddComponentMenu(Strings.ExamplesMenuPrefix + "Game Kit - Character State")]
[HelpURL(Strings.DocsURLs.ExampleAPIDocumentation + nameof(AnimatorControllers) + "." + nameof(GameKit) + "/" + nameof(CharacterState))]
public abstract class CharacterState : StateBehaviour, IOwnedState<CharacterState>, IState

Examples

3D Game Kit

Attributes

Type Description
AddComponentMenu
HelpURLAttribute

Properties

Name Value Summary
CanEnterState bool
[Animancer.FSM.IState.CanEnterState] Determines whether the Animancer.FSM.StateMachine`1 can enter this state. Always returns true unless overridden.
Inherited from StateBehaviour
CanExitState bool
[Animancer.FSM.IState.CanExitState] Determines whether the Animancer.FSM.StateMachine`1 can exit this state. Always returns true unless overridden.
Inherited from StateBehaviour
Character Character
FullMovementControl bool
Indicates whether the root motion applied each frame while this state is active should be constrained to only move in the specified CharacterBrain.Movement. Otherwise the root motion can move the Animancer.Examples.AnimatorControllers.GameKit.CharacterState.Character in any direction. Default is true.
OwnerStateMachine StateMachine<CharacterState>
The Animancer.FSM.StateMachine`1 that this state is used in.
RootMotion Vector3
Some states (such as Animancer.Examples.AnimatorControllers.GameKit.AirborneState) will want to apply their own source of root motion, but most will just use the root motion from the animations.
StickToGround bool
Jumping enters the Animancer.Examples.AnimatorControllers.GameKit.AirborneState, but UnityEngine.CharacterController.isGrounded doesn't become false until after the first update, so we want to make sure the Animancer.Examples.AnimatorControllers.GameKit.CharacterState.Character won't stick to the ground during that update.

Methods

Name Value Summary
OnEnterState() void
[Animancer.FSM.IState.OnEnterState] Asserts that this component isn't already enabled, then enables it.
Inherited from StateBehaviour
OnExitState() void
[Animancer.FSM.IState.OnExitState] Asserts that this component isn't already disabled, then disables it.
Inherited from StateBehaviour
OnValidate() void
[Editor-Only] States start disabled and only the current state gets enabled at runtime.