A FlexMotion container that allows animation blending via the modification of the FlexMotionLayer's blend weights.

This type of container actually works similarly as the 1D variant but with a set number of clips to facilitate 2d blending. It is indeed possible to reproduce the 2D blending variants of FlexMotion containers with a 1D variant.

The set of clips corresponds to the 4 cardinal directions and one neutral state. A classic example is one idle animation and 4 movement animations, one per direction.

Like the 1D variant, it has a blend range and an equalized lengths type settings. Refer to the FlexMotion 1D section of the documentation for more information about these settings.

2D Blending is done via the FlexMotionLayer dedicated method called Compute2dBlendWeight. This method takes a Vector2 with values ranging from -1 to 1 with the x-axis corresponding to the left / right clips and the y axis to the down / up clips.

For example, with a default blend range (0f, 1f), a blend value of (-0.125f, 0.5f) will result in a blend between the neutral (~48%), the up (~42%) and the left (~10%) clips.

Here is an example script for 2d blending:

using SV.FlexMotion;
using UnityEngine;

public class Use2dBlending : MonoBehaviour
{
    [SerializeField]
    private FlexMotionAnimator animator;

    [SerializeField]
    private FlexMotion flexMotion;

    private FlexMotionLayer _layer;
    
    private void Start()
    {
        _layer = animator.Play(flexMotion);
    }

    private void Update()
    {
        // Use the mouse position as blend value
        var mp = Input.mousePosition;
        var v = new Vector2(mp.x / Screen.width, mp.y / Screen.height);
        
        // Change the vector's range from (0f, 1f) to (-1f, 1f)
        v *= 2f;
        v -= Vector2.one;
        
        _layer.Compute2dBlendWeight(v);
    }
}

The script allows you to test 2d blending by moving your mouse around the screen as follows: