Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

guided animation: conceptional tips required

Discussion in 'Animation' started by merkosh, Feb 23, 2015.

  1. merkosh

    merkosh

    Joined:
    Feb 10, 2015
    Posts:
    2
    Being new to Unity I need to achieve the following task; I have some ideas on how to accomplish it and my question is, whether this is a suitable way of doing it or whether a more experienced user would go about it some other way?

    Task: I receive a knee angle of a squatting exercise by a human from an external source. I need to animate an avatar to visualize the person in realtime. My problem is that I don't know how to do a controlled animation like that.

    Solution 1:
    Create an Animation Clip of the complete motion (3DS Max); import it into Unity and split it into a set of clips of several frames each. Using the Animator I combine these clips to a (rather large) state machine and change state, depending on the current knee angle; I will also need to estimate the speed from the angles and adjust the Animation Clip playback speed to keep up with the human.

    Solution 2:
    Create an Animation Clip as above, but don't use the Animator state machine. Instead I could poll the knee angle in a script and adjust the playback speed in a control loop and try to keep the knee angle as close to the received values as possible.

    Solution 3:
    Do not use an Animation Clip, but set the knee angles manually from a script. I would have to manually translate the upper body up- and downwards, as well as to manually rotate the upper body forward during the squat execution. I am hoping the Foot IK would be able to compensate for the ankle flection so the avatar stays on the floor.

    Suggestions?
    Thanks in advance!
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    What about using a blend tree? Prepare two animation clips: (1) standing fully erect and (2) lowest measurable squat. Make the knee angle a Mecanim parameter, and blend on this parameter. You only need to use Animator.SetFloat() to set it, and the blend tree will take care of blending to the right angle.

    For ankle flexion, consider using Final IK. It's an expense, but it does more sophisticated IK than Unity's built-in IK. The foot IK in particular is very good.
     
    theANMATOR2b likes this.
  3. merkosh

    merkosh

    Joined:
    Feb 10, 2015
    Posts:
    2
    Wow. After some testing, that looks promising, thank you!