Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Mixamo strafing animation moving slightly on the Z-Axis

Discussion in 'Animation' started by Vallar, Jul 15, 2018.

  1. Vallar

    Vallar

    Joined:
    Oct 18, 2012
    Posts:
    177
    Hi,

    I am using the strafing animations available from Mixamo and usually they work quite well. However today I was testing Root Motion and imported the strafe animations. Leaving everything to defaults the character runs at NE or NW instead of East or West in strafing. So I added an offset until the Z-Axis velocity was zeroed out. Yet, it still moving in the Z-Axis. Any ideas what I can do to fix this?



    Thanks.
     
    marcospgp likes this.
  2. Vallar

    Vallar

    Joined:
    Oct 18, 2012
    Posts:
    177
    Bump, still looking for a fix for this problem.

    Tried another animation file I downloaded off the asset store (strafing) and it did the same thing. Any ideas what is wrong?
     
  3. gambitslacklines

    gambitslacklines

    Joined:
    Feb 23, 2015
    Posts:
    14
    It is Strafing because you have "Trimmed" the clip.

    The Blending of the loop happens based on the bone Positions, if you trim down a clip the start and end positions will not match, and unity will blend them like seen in your gif.

    You can try setting the rotation settings to "bake", then it should snap back onces the new loop starts.

    I would not focus to much on what you see in the small clip window and check how all works out when it is placed in the animator.
     
  4. Vallar

    Vallar

    Joined:
    Oct 18, 2012
    Posts:
    177
    I didn't trim or change anything in the clip. It is as is from Mixamo.

    I did try checking Bake Into Pose in Rotation and zeroing out the z-axis again based on the bake. Didn't work. I tried leaving it as is without zeroing it out (after checking Bake Into Pose) and it still had the veering problem.

    I actually tested this in game and it is exactly as you see in the animation preview. The character veers off in the z-axis in both the strafing right and strafing left animations.
     
  5. gambitslacklines

    gambitslacklines

    Joined:
    Feb 23, 2015
    Posts:
    14
    "I didn't trim or change anything in the clip. It is as is from Mixamo. "

    You did, it is visible in your gif, you changed the end Frame.
    The original file has 30 frames, but you trimmed it to end the loop at 20.
     
    marcospgp likes this.
  6. Vallar

    Vallar

    Joined:
    Oct 18, 2012
    Posts:
    177
    By default when imported the animation is set to end at 20. Moreover, if I move the tracker to 30 instead of 20, there are 10 empty frames which makes the animation not loop correctly. Sorry, but no, I didn't trim anything like I said.
     
  7. gambitslacklines

    gambitslacklines

    Joined:
    Feb 23, 2015
    Posts:
    14
    Well then i really don't know, sorry.

    The fact that the XZ axis Transform setting shows you a big red light should give you the hint that the loop does not match, which causes strafing like mentioned before.

    I do not know if it is maybee a export error of mixamo, cause you should not have any empty frames anyways.

    You can try to check the file in a modelling programm.
     
  8. Vallar

    Vallar

    Joined:
    Oct 18, 2012
    Posts:
    177
    At first I thought it is probably the export like you mentioned and I went to Mixamo and double checked the animation on the website. It worked flawlessly so I ignored Mixamo and imported a package with some animations from the store (called RPG Animation or something of the sort) and the same issue was there, even with the red light on the XZ axis. I tried fixing it, but it is the same thing. So I am guessing this isn't native to Mixamo and something to do with Unity but I am not sure how to fix it.

    Either way, my guess with the red light on XZ is because the animation starts at a position and ends in another (this is Root Motion after all). Which would make sense. But the veering doesn't.
     
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,528
    Try ticking Root Transform Rotation > Bake Into Pose.

    Also, what happens if you change the offset from -0.67 to 0.0?
     
    Vallar likes this.
  10. Vallar

    Vallar

    Joined:
    Oct 18, 2012
    Posts:
    177
    That actually did the trick. Thank you very much. Once I hit Bake Into Pose and left the velocity in z as is without trying to zero it out, it actually worked. Which is a bit surprising given there is a velocity but I guess Bake Into Pose overrides everything.
     
  11. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,528
    Glad to help. BTW, when Bake Into Pose is ticked, offset is ignored.
     
  12. Vallar

    Vallar

    Joined:
    Oct 18, 2012
    Posts:
    177
    I thought that too. But for some reason if I have offset set to anything (the field below Bake Into Pose) it makes the character veer off in z-axis. Unless you mean offset in the velocity not the field below Bake Into Pose. But if whatever value in the offset field shouldn't be taken into account when the Bake Into Pose is ticked, then this might be a bug that needs to be reported.
     
    gambitslacklines likes this.
  13. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,528
    Or the documentation might be wrong. I haven't tested it myself in a while.
     
  14. Vallar

    Vallar

    Joined:
    Oct 18, 2012
    Posts:
    177
    I'll go with the documentation is wrong, feels more natural and akin to Unity that way :D
     
  15. gambitslacklines

    gambitslacklines

    Joined:
    Feb 23, 2015
    Posts:
    14
    Bake-Into-Pose makes the animation use what is saved in its curves(which will also make it snap to the start position which is saved in the fbx), if you unclick it you get what is usually known as "inplace-animation".

    So the question is if you really want to use the baked movement curve for the z and x axis and manipulate its speed, or if you want to handle the movement of the transform by code and just match the animation speed to make it look right.

    I prefer the last version.
     
  16. Vallar

    Vallar

    Joined:
    Oct 18, 2012
    Posts:
    177
    Interesting, if I check Bake-Into-Pose, the character sticks to its start location and doesn't move. If I untick it, it starts moving. Perhaps that happens when Root Motion is active in the Animator and is reversed when it isn't active. But that is what I have.

    That said, I also prefer controlling the character in code and just setting animations. However lately I started lering about Root Motion and saw how easy it is to get a character setup. So thought I keep on learning and see what kind of issues I may run into.
     
  17. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,528
    Root motion allows the animation to move the character (as long as the animation clip has root motion in it), versus moving it in code. Root motion can give you more realistic-looking motion because motion is usually not constant. A character typically accelerates and decelerates with each footstep.

    If you tick Root Transform Position > Bake Into Pose, it will remove the forward/sideways root motion info from the animation clip. It worked to tick Root Transform Rotation > Bake Into Pose because this removes the rotation root motion info. The rotation was what was causing the character to veer off course.
     
    Last edited: Sep 25, 2019
    gambitslacklines likes this.
  18. Vallar

    Vallar

    Joined:
    Oct 18, 2012
    Posts:
    177
    That is precisely my current understanding. Bake Into Pose, locks the current animation in place + ignores any applied "forces" from the Root Motion. Though I didn't know (before you suggested) that if there is still velocity displayed that I shouldn't add an offset to zero out the velocity. But it makes sense, if Bake-Into-Pose locks the animation and eliminates its forces, then yeah, shouldn't mess with offset when I have it enabled. Thanks for clarifying that :)
     
  19. Gamelton

    Gamelton

    Joined:
    Oct 18, 2016
    Posts:
    1
    In Animation setting under Root transform rotation change Body Orientation to Original
     
    marcospgp and rdhall99 like this.