Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

[SOLVED] Miss-matched HumanPartDofs when instantiating MuscleHandles

Discussion in '2019.2 Beta' started by Davedub, May 28, 2019.

  1. Davedub

    Davedub

    Joined:
    Mar 30, 2016
    Posts:
    22
    I am looking at ways of mixing externally streamed animation data with regular animations. I am currently working with the Playables API and the UnityEngine Experimental Animations.

    I have hit an issue with the body part enumerations when creating MuscleHandles. For example, these will always work as expected:

    Code (csharp):
    1. mAnimationJob.LeftUpperLegInOut = new MuscleHandle(HumanPartDof.LeftLeg, LegDof.UpperLegInOut);
    2. mAnimationJob.RightHandDownUp = new MuscleHandle(HumanPartDof.RightArm, ArmDof.HandDownUp);
    In general, there are no issues in creating MuscleHandles for the arms and legs. However, if I try the same thing with the Body and Head HumanPartDofs like this:

    Code (csharp):
    1. mAnimationJob.SpineFrontBack = new MuscleHandle(HumanPartDof.Body, BodyDof.SpineFrontBack);
    2. mAnimationJob.HeadTurnLeftRight = new MuscleHandle(HumanPartDof.Head, HeadDof.HeadRollLeftRight);
    I get errors like this:

    Code (csharp):
    1. Assets\Scripts\PlayableAnimationExperiment.cs(93,70): error CS1503: Argument 2: cannot convert from 'UnityEngine.BodyDof' to 'UnityEngine.LegDof'
    2. Assets\Scripts\PlayableAnimationExperiment.cs(107,73): error CS1503: Argument 2: cannot convert from 'UnityEngine.HeadDof' to 'UnityEngine.LegDof'
    i.e. It's expecting a LegDof for SpineFrontBack and expecting a LegDof for HeadRollLeftRight for some un-intuitive reason.

    Is this a bug, or am I missing something?

    (Demonstration script attached. Unity versions 2019.2.0b2 and 2019.2.0b3 on Win10)
     

    Attached Files:

  2. Davedub

    Davedub

    Joined:
    Mar 30, 2016
    Posts:
    22
    This was due to user error - when instantiating MuscleHandles for the Head and Body parts, only the BodyDof part is needed. So my line

    Code (csharp):
    1. mAnimationJob.SpineFrontBack = new MuscleHandle(HumanPartDof.Body, BodyDof.SpineFrontBack);
    ...wouldn't compile, as I'd specified a HumanPartDof. This is unnecessary in the case of Head and Body parts, as the body part being referenced is explicit in the BodyDof (SpineFrontBack in the above case). This of course is not the case for Arm and Leg HumanPartDofs, as there is a need to differentiate between left and right limbs.

    The correct way to do the above is:

    Code (csharp):
    1. mAnimationJob.SpineFrontBack = new MuscleHandle(BodyDof.SpineFrontBack);