layer at index 0 is the Base layer in the animator controller.
in layer at index 1 i have a layer name Pointing.
at the top:
private float LayerWeightTarget = 0;
private float CurrentLayerWeight = 0;
private int layerIndex = 0;
in the Update
private void Update()
{
// Determine if the character should be pointing
bool shouldPoint = lastPrimaryTarget != null && fingerPointing;
LayerWeightTarget = shouldPoint ? 1.0f : 0.0f;
// Update the current layer weight towards the target weight
if (Mathf.Abs(CurrentLayerWeight - LayerWeightTarget) > 0.01f) // Adding a threshold to prevent continuous updates
{
CurrentLayerWeight += (LayerWeightTarget - CurrentLayerWeight) * 0.125f; // Smoothing the transition
animator.SetLayerWeight(layerIndex, CurrentLayerWeight);
}
}
but it’s not making smooth transition between the layers.
once the player is not pointing it keep “jumping” to the other layer and back when the player is pointing again there is a “jumping” to the first layer. it’s not smooth transition.