Search Unity

[SOLVED] Issue with matching HumanPartDofs with MuscleHandle

Discussion in 'Animation' started by Davedub, May 26, 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'
    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:

    Last edited: May 26, 2019
  2. Davedub

    Davedub

    Joined:
    Mar 30, 2016
    Posts:
    22
    Hmm - no replies. Am going to re-post in the Betas & Experimental Features forum. Please feel free to close this version
     
  3. 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);
     
  4. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    should this script do anything as it is? I expected not.

    but if I add it to an animated character, it seems to change rootmotion
    switched off
    playable0.gif
    switched on
    playable1.gif
     
  5. Davedub

    Davedub

    Joined:
    Mar 30, 2016
    Posts:
    22
    The script was only to demonstrate the compilation error...
     
  6. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    yes, but the corrected one

    is it a bug? or this is expected
     

    Attached Files:

    Davedub likes this.
  7. Davedub

    Davedub

    Joined:
    Mar 30, 2016
    Posts:
    22
    I didn't upload a script with the corrected code - the corrected code is only shown in my second post.

    To surmise - the purpose of the 1st post was to show that this wouldn't compile (due to my error):

    Code (csharp):
    1. mAnimationJob.SpineFrontBack = new MuscleHandle(HumanPartDof.Body, BodyDof.SpineFrontBack);
    The purpose of the second post was to show that this is the correct way to instantiate a MuscleHandle that is not a limb:

    Code (csharp):
    1. mAnimationJob.SpineFrontBack = new MuscleHandle(BodyDof.SpineFrontBack);
    That's all there is to it!