Documentation

Unity Engine

Download Unity

Unity Engine

ComputeBlendSpace2DSimpleDirectionalWeights(float2, NativeArray<float2>, NativeArray<float>)

Computes the weights of a 2D simple directional blend space.
Read time 2 minutesLast updated 4 hours ago

Definition

public static void ComputeBlendSpace2DSimpleDirectionalWeights(float2 input, NativeArray<float2> values, NativeArray<float> outWeights)

Parameters

input

The position of the input in the blend space plane, in the same space as the positions in
values
.

The position of each animation in the blend space.

The array that receives the weight of each animation. Its length must equal the length of
values
.

Remarks

Use this method when the animations sit in different directions around an optional center point, for example walk animations in four directions. For other layouts, use BlendSpaceUtility.ComputeBlendSpace2DFreeformWeights.
Each animation has a position in the plane. An animation at
(0, 0)
is the center animation. On each side of the input direction, the method picks the animation whose direction is closest to the direction of the input, and blends the two picks with the center animation. The closer the input is to
(0, 0)
, the more weight the center animation gets. If no animation sits on one side of the input direction, the center gets all the weight. If no animation sits at
(0, 0)
, the weight of the center is divided equally among all animations.
Only the direction of a position, not its distance from the center, selects an animation. If several animations sit in the same direction from the center, the method picks only one of them.
Place at most one animation at
(0, 0)
. If two or more animations sit at
(0, 0)
and the input isn't
(0, 0)
, the method sets every weight to 0. This matches the 2D Simple Directional blend tree.
This method needs only the positions of the animations. The freeform method needs a FreeformBlendSpace2DData that you create once for the positions.