public sealed class BlendTree2DMotions on a plane, blended by two parameters: a locomotion set driven by forward and sideways speed, or an aim set driven by yaw and pitch.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Gradient band interpolation, which is Rune Skovbo Johansen's construction and what Unity's freeform modes use. For each motion, the weight is how far the sample point is from crossing into any other motion's territory: one minus the projection of p − pᵢ onto pⱼ − pᵢ, taken over every other motion j and minimised, clamped at zero, and normalised at the end.
What that buys over the obvious alternatives: inverse-distance weighting gives every motion a non-zero weight everywhere, so a backward walk is always slightly playing during a forward run; a Delaunay triangulation gives exact barycentric weights and needs a triangulation, which is a build step, a degenerate-case problem, and something that has to be rebuilt when an artist drags a motion. Gradient bands need nothing precomputed, reach exactly one at each motion's own point, and reach exactly zero outside a bounded neighbourhood of it.
Directional mode compares angles, not positions. A run-forward at (0, 3) and a run-backward at (0, −3) are five metres per second apart in Cartesian terms and are opposite directions of travel; a sample halfway between them is a standing character, and Cartesian weights would say "half of each" — a character running forwards and backwards at once. Directional mode maps each pair into (relative magnitude, signed angle) before doing the same construction, which puts the halfway point where a person would draw it.
Fields and properties (4)
public int ParameterXThe index of the parameter on the horizontal axis.
public int ParameterYThe index of the parameter on the vertical axis.
public Blend2DMode ModeHow positions are compared.
public ReadOnlySpan<BlendTree2DChild> ChildrenThe motions and their positions.
Methods (5)
public BlendTree2D(int parameterX, int parameterY, IEnumerable<BlendTree2DChild> children, Blend2DMode mode = FreeformCartesian)Builds a tree.
public BlendTree2D(AnimationParameters parameters, string parameterX, string parameterY, IEnumerable<BlendTree2DChild> children, Blend2DMode mode = FreeformCartesian)Builds a tree, declaring its parameters if they are not already.
public override float Length(AnimationParameters parameters)How long one pass takes at the current parameters, in seconds.
public override RootMotionDelta Evaluate(in MotionContext context, Span<BoneTransform> destination)Poses the skeleton, and reports what the root did.
public void ComputeWeights(AnimationParameters parameters, Span<float> destination)The weights a point produces, for a test or an editor.
Used by (2)
- BlendTreeTestsVixen.Animation.Tests
- AnimationGraphCompilerVixen.Editor.AnimationGraph