unreal.AnimDistanceMatchingLibrary

class unreal.AnimDistanceMatchingLibrary(outer=None, name='None')

Bases: unreal.BlueprintFunctionLibrary

Library of techniques for driving animations by distance metrics rather than by time. These techniques can be effective at compensating for differences between character movement and authored motion in the animations. Distance Matching effectively changes the play rate of the animation to keep the feet from sliding. It’s common to clamp the resulting play rate to avoid animations playing too slow or too fast and to use techniques such as Stride Warping to make up the difference.

C++ Source:

  • Plugin: AnimationLocomotionLibrary

  • Module: AnimationLocomotionLibraryRuntime

  • File: AnimDistanceMatchingLibrary.h

classmethod advance_time_by_distance_matching(update_context, sequence_evaluator, distance_traveled, distance_curve_name, play_rate_clamp=[0.750000, 1.250000]) SequenceEvaluatorReference

Advance the sequence evaluator forward by distance traveled rather than time. A distance curve is required on the animation that describes the distance traveled by the root bone in the animation. See UDistanceCurveModifier.

Parameters
  • update_context (AnimUpdateContext) – The update context provided in the anim node function.

  • sequence_evaluator (SequenceEvaluatorReference) – The sequence evaluator node to operate on.

  • distance_traveled (float) – The distance traveled by the character since the last animation update.

  • distance_curve_name (Name) – Name of the curve we want to match

  • play_rate_clamp (Vector2D) – A clamp on the effective play rate of the animation after distance matching. Set to (0,0) for no clamping.

Return type

SequenceEvaluatorReference

classmethod distance_match_to_target(sequence_evaluator, distance_to_target, distance_curve_name) SequenceEvaluatorReference

Set the time of the sequence evaluator to the point in the animation where the distance curve matches the DistanceToTarget input. A common use case is to achieve stops without foot sliding by, each frame, selecting the point in the animation that matches the distance the character has remaining until it stops. Note that because this technique sets the time of the animation by distance remaining, it doesn’t respect phase of any previous animation (e.g. from a jog cycle).

Parameters
  • sequence_evaluator (SequenceEvaluatorReference) – The sequence evaluator node to operate on.

  • distance_to_target (float) – The distance remaining to a target (e.g. a stop or pivot point).

  • distance_curve_name (Name) – Name of the curve we want to match

Return type

SequenceEvaluatorReference

classmethod set_playrate_to_match_speed(sequence_player, speed_to_match, play_rate_clamp=[0.750000, 1.250000]) SequencePlayerReference

Set the play rate of the sequence player so that the speed of the animation matches in-game movement speed. While distance matching is commonly used for transition animations, cycle animations (walk, jog, etc) typically just adjust their play rate to match the in-game movement speed. This function assumes that the animation has a constant speed.

Parameters
  • sequence_player (SequencePlayerReference) – The sequence player node to operate on.

  • speed_to_match (float) – The in-game movement speed to match. This is usually the current speed of the movement component.

  • play_rate_clamp (Vector2D) – A clamp on how much the animation’s play rate can change to match the in-game movement speed. Set to (0,0) for no clamping.

Return type

SequencePlayerReference