KROYSDOCS
HomeWhat's newv0.1.0

Animator

Drives an entity's Animator from scripts: the parameters its controller's transitions and blend trees read (bool, float, int, trigger), the events its clips raise, and playback settings such as speed and root motion.

Kindclass
NamespaceKroys.EngineScripting
Members57
SourceAnimator.cs, Generated/NativeComponents.g.cs
EXAMPLE

In a script

Parameters are the ones defined in the Animator window; setting a name that does not exist does nothing (check with HasParameter). Animation updates every frame, so set parameters from OnUpdate.

Component access: every member takes the entity first, for example Animator.Has(Entity). The values are the ones the Inspector shows for this component.

Gameplay.cs
public sealed class LocomotionAnimation : EntityScript
{
    protected override void OnUpdate(float deltaTime)
    {
        if (!Animator.Has(Entity) || !CharacterController.Has(Entity)) return;
        // The character moves in fixed steps; its achieved velocity is steady between them,
        // so reading it every frame gives a smooth animation speed.
        Vector3 velocity = CharacterController.GetAchievedVelocity(Entity);
        Animator.SetFloat(Entity, "Speed", new Vector2(velocity.X, velocity.Z).Length());
        Animator.SetBool(Entity, "Grounded", CharacterController.IsGrounded(Entity));
        if (Input.IsActionPressed("Jump"))
            Animator.SetTrigger(Entity, "Jump");
    }

    protected override void OnAnimationEvent(AnimationEvent animationEvent)
    {
        // Markers placed on a clip in the Animator arrive the moment the pose crosses them.
        if (animationEvent.Name == "Footstep")
            Debug.Log("step");
    }
}
REFERENCE

Members

Methods
#public static bool Has(Entity entity)
Whether the entity has an Animator component.
methodstatic
#public static bool HasParameter(Entity entity, string name)
Whether the entity's animator controller has a parameter with this name.
methodstatic
#public static bool GetBool(Entity entity, string name)
The current value of a bool parameter (false when it does not exist).
methodstatic
#public static void SetBool(Entity entity, string name, bool value)
Sets a bool parameter of the animator controller; transitions that test it react on the next animation update.
methodstatic
#public static float GetFloat(Entity entity, string name)
The current value of a float parameter (0 when it does not exist).
methodstatic
#public static void SetFloat(Entity entity, string name, float value)
Sets a float parameter, for example a speed that drives a blend tree.
methodstatic
#public static int GetInt(Entity entity, string name)
The current value of an int parameter (0 when it does not exist).
methodstatic
#public static void SetInt(Entity entity, string name, int value)
Sets an int parameter.
methodstatic
#public static void SetTrigger(Entity entity, string name)
Sets a trigger parameter: it stays set until a transition consumes it or ResetTrigger clears it.
methodstatic
#public static void ResetTrigger(Entity entity, string name)
Clears a trigger parameter that no transition has consumed yet.
methodstatic
#public static bool SetLookAtWeight(Entity entity, string name, float weight)
Sets the weight of an existing named look-at chain. Returns false for invalid input or a missing chain.
methodstatic
#public static bool SetSpineLean(Entity entity, float degrees, Vector3 lookForward = default)
Bends the spine this frame onward, keeping hips and legs where they are. IK and look-at chains follow. Positive leans right of lookForward, the world direction being looked along. Pass it for any stance that turns the chest aside; left at zero, the lean follows the chest.
methodstatic
#public static int GetEventCount(Entity entity)
Number of animation event markers the animator crossed in its last update (OnAnimationEvent receives them too).
methodstatic
#public static string GetEventName(Entity entity, int eventIndex)
Name of the event marker at this index of the last update.
methodstatic
#public static string GetEventStringPayload(Entity entity, int eventIndex)
String payload of the event marker at this index.
methodstatic
#public static string GetEventFunctionName(Entity entity, int eventIndex)
Function name stored on the event marker at this index.
methodstatic
#public static bool EventHasPayload(Entity entity, int eventIndex)
Whether the event marker at this index carries a number payload.
methodstatic
#public static float GetEventPayload(Entity entity, int eventIndex)
Number payload of the event marker at this index (0 without one).
methodstatic
#public static bool IsEnabled(Entity entity)
Reads the Animator component's Enabled value of the entity.
methodstatic
#public static void SetEnabled(Entity entity, bool value)
Sets the Animator component's Enabled value on the entity.
methodstatic
#public static bool IsPlaying(Entity entity)
Reads the Animator component's Playing value of the entity.
methodstatic
#public static void SetPlaying(Entity entity, bool value)
Sets the Animator component's Playing value on the entity.
methodstatic
#public static bool IsRootMotionApplied(Entity entity)
Reads the Animator component's Root Motion Applied value of the entity.
methodstatic
#public static void SetApplyRootMotion(Entity entity, bool value)
Sets the Animator component's Apply Root Motion value on the entity.
methodstatic
#public static Vector3 GetLastRootMotionDelta(Entity entity)
Reads the Animator component's Last Root Motion Delta value of the entity.
methodstatic
#public static Vector3 GetLastRootMotionEulerDelta(Entity entity)
Reads the Animator component's Last Root Motion Euler Delta value of the entity.
methodstatic
#public static float GetSpeed(Entity entity)
Reads the Animator component's Speed value of the entity.
methodstatic
#public static void SetSpeed(Entity entity, float value)
Sets the Animator component's Speed value on the entity.
methodstatic
#public static float GetCurrentTime(Entity entity)
Reads the Animator component's Current Time value of the entity.
methodstatic
#public static void SetCurrentTime(Entity entity, float value)
Sets the Animator component's Current Time value on the entity.
methodstatic
#public static string GetCurrentState(Entity entity)
Reads the Animator component's Current State value of the entity.
methodstatic
#public static string GetNextState(Entity entity)
Reads the Animator component's Next State value of the entity.
methodstatic
#public static void SetNextState(Entity entity, string value)
Sets the Animator component's Next State value on the entity.
methodstatic
#public static ulong GetSkeleton(Entity e)
Reads the Animator component's Skeleton value of the entity.
methodstatic
#public static void SetSkeleton(Entity e, ulong value)
Sets the Animator component's Skeleton value on the entity.
methodstatic
#public static ulong GetRig(Entity e)
Reads the Animator component's Rig value of the entity.
methodstatic
#public static void SetRig(Entity e, ulong value)
Sets the Animator component's Rig value on the entity.
methodstatic
#public static ulong GetRigDefinition(Entity e)
Reads the Animator component's Rig Definition value of the entity.
methodstatic
#public static void SetRigDefinition(Entity e, ulong value)
Sets the Animator component's Rig Definition value on the entity.
methodstatic
#public static ulong GetClip(Entity e)
Reads the Animator component's Clip value of the entity.
methodstatic
#public static void SetClip(Entity e, ulong value)
Sets the Animator component's Clip value on the entity.
methodstatic
#public static ulong GetController(Entity e)
Reads the Animator component's Controller value of the entity.
methodstatic
#public static void SetController(Entity e, ulong value)
Sets the Animator component's Controller value on the entity.
methodstatic
#public static bool GetLoop(Entity e)
Reads the Animator component's Loop value of the entity.
methodstatic
#public static void SetLoop(Entity e, bool value)
Sets the Animator component's Loop value on the entity.
methodstatic
#public static bool GetEnableAnimationLayers(Entity e)
Reads the Animator component's Enable Animation Layers value of the entity.
methodstatic
#public static void SetEnableAnimationLayers(Entity e, bool value)
Sets the Animator component's Enable Animation Layers value on the entity.
methodstatic
#public static bool GetEnableIk(Entity e)
Reads the Animator component's Enable Ik value of the entity.
methodstatic
#public static void SetEnableIk(Entity e, bool value)
Sets the Animator component's Enable Ik value on the entity.
methodstatic
#public static string GetInitialState(Entity e)
Reads the Animator component's Initial State value of the entity.
methodstatic
#public static void SetInitialState(Entity e, string value)
Sets the Animator component's Initial State value on the entity.
methodstatic
#public static bool GetManualPoseEnabled(Entity e)
Reads the Animator component's Manual Pose Enabled value of the entity.
methodstatic
#public static void SetManualPoseEnabled(Entity e, bool value)
Sets the Animator component's Manual Pose Enabled value on the entity.
methodstatic
#public static bool GetShowBones(Entity e)
Reads the Animator component's Show Bones value of the entity.
methodstatic
#public static void SetShowBones(Entity e, bool value)
Sets the Animator component's Show Bones value on the entity.
methodstatic
#public static bool GetRenderBonesInFront(Entity e)
Reads the Animator component's Render Bones In Front value of the entity.
methodstatic
#public static void SetRenderBonesInFront(Entity e, bool value)
Sets the Animator component's Render Bones In Front value on the entity.
methodstatic
Signatures
public static bool Has(Entity entity)
public static bool HasParameter(Entity entity, string name)
public static bool GetBool(Entity entity, string name)
public static void SetBool(Entity entity, string name, bool value)
public static float GetFloat(Entity entity, string name)
public static void SetFloat(Entity entity, string name, float value)
public static int GetInt(Entity entity, string name)
public static void SetInt(Entity entity, string name, int value)
public static void SetTrigger(Entity entity, string name)
public static void ResetTrigger(Entity entity, string name)
public static bool SetLookAtWeight(Entity entity, string name, float weight)
public static bool SetSpineLean(Entity entity, float degrees, Vector3 lookForward = default)
public static int GetEventCount(Entity entity)
public static string GetEventName(Entity entity, int eventIndex)
public static string GetEventStringPayload(Entity entity, int eventIndex)
public static string GetEventFunctionName(Entity entity, int eventIndex)
public static bool EventHasPayload(Entity entity, int eventIndex)
public static float GetEventPayload(Entity entity, int eventIndex)
public static bool IsEnabled(Entity entity)
public static void SetEnabled(Entity entity, bool value)
public static bool IsPlaying(Entity entity)
public static void SetPlaying(Entity entity, bool value)
public static bool IsRootMotionApplied(Entity entity)
public static void SetApplyRootMotion(Entity entity, bool value)
public static Vector3 GetLastRootMotionDelta(Entity entity)
public static Vector3 GetLastRootMotionEulerDelta(Entity entity)
public static float GetSpeed(Entity entity)
public static void SetSpeed(Entity entity, float value)
public static float GetCurrentTime(Entity entity)
public static void SetCurrentTime(Entity entity, float value)
public static string GetCurrentState(Entity entity)
public static string GetNextState(Entity entity)
public static void SetNextState(Entity entity, string value)
public static ulong GetSkeleton(Entity e)
public static void SetSkeleton(Entity e, ulong value)
public static ulong GetRig(Entity e)
public static void SetRig(Entity e, ulong value)
public static ulong GetRigDefinition(Entity e)
public static void SetRigDefinition(Entity e, ulong value)
public static ulong GetClip(Entity e)
public static void SetClip(Entity e, ulong value)
public static ulong GetController(Entity e)
public static void SetController(Entity e, ulong value)
public static bool GetLoop(Entity e)
public static void SetLoop(Entity e, bool value)
public static bool GetEnableAnimationLayers(Entity e)
public static void SetEnableAnimationLayers(Entity e, bool value)
public static bool GetEnableIk(Entity e)
public static void SetEnableIk(Entity e, bool value)
public static string GetInitialState(Entity e)
public static void SetInitialState(Entity e, string value)
public static bool GetManualPoseEnabled(Entity e)
public static void SetManualPoseEnabled(Entity e, bool value)
public static bool GetShowBones(Entity e)
public static void SetShowBones(Entity e, bool value)
public static bool GetRenderBonesInFront(Entity e)
public static void SetRenderBonesInFront(Entity e, bool value)

KroysEngine 0.1.0 documentation, built from the engine repository by Tools/BuildDocsSite.py.