// Animancer // Copyright 2020 Kybernetik //
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value.
using Animancer.FSM;
using UnityEngine;
namespace Animancer.Examples.AnimatorControllers.GameKit
{
///
/// Base class for the various states a can be in and actions they can perform.
///
[AddComponentMenu(Strings.MenuPrefix + "Examples/Game Kit - Creature State")]
[HelpURL(Strings.APIDocumentationURL + ".Examples.AnimatorControllers.GameKit/CreatureState")]
public abstract class CreatureState : StateBehaviour,
IOwnedState
{
/************************************************************************************************************************/
[SerializeField]
private Creature _Creature;
/// The that owns this state.
public Creature Creature
{
get { return _Creature; }
}
#if UNITY_EDITOR
protected void Reset()
{
_Creature = Editor.AnimancerEditorUtilities.GetComponentInHierarchy(gameObject);
}
#endif
/************************************************************************************************************************/
public StateMachine OwnerStateMachine { get { return _Creature.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 { get { return 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 { get { return _Creature.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 { get { return true; } }
/************************************************************************************************************************/
}
}