I have created an animator controller which contains a blend tree of type “2D Freeform Cartesian”. The blend tree holds two parameters ‘Grip’, and ‘Trigger’ and appears to animate the hand prefab as I would expect when I pass the prefab into the preview window like so :
I have added an animator and the ‘Left Hand Animator’ controller to the prefab :
Here is some of the initialisation code where the ‘handGameObject’ here is a created instance of the ‘Left Hand Model’ prefab that’s instantiated.
handGameObject = Instantiate(handModelPrefab, transform);
handAnimator = handGameObject.GetComponent<Animator>();
And here is the code I am using to update the animations ‘Grip’ and ‘Trigger’ parameters :
private void UpdateHandAnimation()
{
if (tgtDevice.TryGetFeatureValue(CommonUsages.trigger, out var triggerValue))
{
handAnimator.SetFloat("Trigger", triggerValue);
}
handAnimator.SetFloat("Trigger", 0.0f);
if (tgtDevice.TryGetFeatureValue(CommonUsages.grip, out var gripValue))
{
handAnimator.SetFloat("Grip", gripValue);
}
handAnimator.SetFloat("Grip", 0.0f);
}
The problem is, I cannot get the hand models to animate in game. I have checked that ‘triggerValue’ and ‘gripValue’ are getting populated correctly at runtime - which they are.
Is there something I am missing?