Search Unity

Making characters sit in a chair - animation snaps forward

Discussion in 'Animation' started by ShaSem, May 7, 2021.

  1. ShaSem

    ShaSem

    Joined:
    Sep 29, 2019
    Posts:
    4
    Hey,

    For the past few days, I've been trying to get my characters to sit in a chair correctly. I've got it down for the most part, but I'm not quite there yet. See the clip at the following link:


    In the animation import settings, I set the Root Motion Node to <Root Transform>, and that definitely makes the sitting animation look good (not setting this results in the character sliding around a bit). However, after the animation, the character suddenly moves forward. I feel like I'm missing a small but crucial part...! I noticed that the capsule collider and navmeshagent stay in the same place. The transform also does not seem to change while the animation plays, but the transform arrows do seem to follow. Hmm.

    Does anyone know what I should do to get this working correctly?

    Thanks in advance,
    Sem
     
  2. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    383
    My FBX import character shifts sideways too but at beginning.
    A lot of devs are experiencing this anomaly so you are not a not alone and good luck trying to fix this.
    Unity has loose variables problem in its animrig system and I dont think its been fully tested.
    One can alter transforms in the animator and the GO responds in the scene. But if one moves the GO in the scene the animator does not reflect. And this could be the missing link.

    I found it. Things are positioned correctly in the scene. You run a clip and the model jumps.
    Click preview and copy a transform value. Unclick preview and paste the value in where you copied it. Toggle 'preview' and the model stays static. At least that is what I just tried and it correction that transform.
     
    Last edited: May 7, 2021
  3. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    670
    this happens because of the difference between the animator.rootpositions of the two clips (sitting down - sitting)

    unity calculates rootposition from the hip* to the ground (of the animation). so you can see when sitting down the center is at feet, then when sitting is played, the center is at the hip.

    *or more precisely center of mass
    https://docs.unity3d.com/Manual/RootMotion.html
    Root Transform is a projection on the Y plane of the Body Transform and is computed at runtime.
    The Body Transform is the mass center of the character.


    what you can do: if your sitting animation is originally centered at feet, setting Root Transform Position (XZ) to Original probably would make the character not move forward when playing sitting animation.
     
    devstudent14 likes this.
  4. ShaSem

    ShaSem

    Joined:
    Sep 29, 2019
    Posts:
    4
    Hey, thanks a lot for the answers!

    This sounds promising - and logical, indeed. Only, how would I center the sitting animation around the feet? I know about baking the animation with Y, XZ, rotation, etc. But I haven’t found any option to change the animation center…

    edit: I think I misread - you probably meant I could do this if the sitting animation was centered around the feet. Sadly, I don’t think it is… Is there anything else I could do?
     
    Last edited: May 8, 2021
  5. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    670
    tests w mixamo anims
    XZ center position [sitting]:
    1. at feet
    2. between hip and feet
    3. at hip


    somewhat baffling that not much difference in the look, but the difference is where the rootXZ ends
    sit1.gif sit2.gif sit3.gif
    usitting.jpg
     
    Last edited: May 8, 2021
  6. ShaSem

    ShaSem

    Joined:
    Sep 29, 2019
    Posts:
    4
    I'm sorry, I seem to be unable to find where to change this option. I'm indeed also using mixamo animations. My import settings for my stand to sit animation are here:

    Or am I looking in the wrong place? If I set the Root Motion Node to <None> instead of <Root Transform>, I can bake some positions in the animation, but I cannot do something with feet on the xz position (only on the y position), so I don't think you mean that.

    As for this, I can find the preview (you mean the small window showing the currently selected animation, right?), but I do not see any transform value there...

    Or am I again looking in the wrong place?

    Thanks again!
     
  7. ShaSem

    ShaSem

    Joined:
    Sep 29, 2019
    Posts:
    4
    …Bump? Still haven’t been able to figure it out :(