// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2024 Kybernetik // #pragma warning disable CS0649 // Field is never assigned to, and will always have its default value. using Animancer.FSM; using UnityEngine; namespace Animancer.Samples.AnimatorControllers.GameKit { /// /// Base class for the various states a can be in and actions they can perform. /// /// /// /// Sample: /// /// 3D Game Kit /// /// /// https://kybernetik.com.au/animancer/api/Animancer.Samples.AnimatorControllers.GameKit/CharacterState /// [AddComponentMenu(Strings.SamplesMenuPrefix + "Game Kit - Character State")] [AnimancerHelpUrl(typeof(CharacterState))] public abstract class CharacterState : StateBehaviour, IOwnedState { /************************************************************************************************************************/ [System.Serializable] public class StateMachine : StateMachine.WithDefault { /************************************************************************************************************************/ [SerializeField] private CharacterState _Locomotion; public CharacterState Locomotion => _Locomotion; [SerializeField] private CharacterState _Airborne; public CharacterState Airborne => _Airborne; /************************************************************************************************************************/ } /************************************************************************************************************************/ [SerializeField] private Character _Character; public Character Character => _Character; /************************************************************************************************************************/ #if UNITY_EDITOR protected override void OnValidate() { base.OnValidate(); gameObject.GetComponentInParentOrChildren(ref _Character); } #endif /************************************************************************************************************************/ public StateMachine OwnerStateMachine => _Character.StateMachine; /************************************************************************************************************************/ /// /// Jumping enters the , but doesn't /// become false until after the first update, so we want to make sure the won't stick /// to the ground during that update. /// public virtual bool StickToGround => true; /// /// Some states (such as ) will want to apply their own source of root motion, but /// most will just use the root motion from the animations. /// public virtual Vector3 RootMotion => _Character.Animancer.Animator.deltaPosition; /// /// Indicates whether the root motion applied each frame while this state is active should be constrained to /// only move in the specified . Otherwise the root motion can /// move the in any direction. Default is true. /// public virtual bool FullMovementControl => true; /************************************************************************************************************************/ } }