Search Unity

Turn character around (180deg) with animation and return to idle animation without flipping back

Discussion in 'Animation' started by hannes_unity965, Oct 18, 2020.

  1. hannes_unity965

    hannes_unity965

    Joined:
    Sep 2, 2019
    Posts:
    9
    Hey Unity people!

    Does anybody know how to turn the character around (rotate 180deg on Y axis) with animation (not with a script) and return to "Idle" animation without flipping back to "Idle" animation's original (rotational) orientation?
    1. Animator has "Apply root motion: On"

    2. I have configured "TurnAround" animation as ..
      Motion > Root motion node: <Root Transform>
      ..so the animation animates turning the character around 180 degrees

    3. After turning around, when the animator returns to "Idle" state, it turns the character around a second time (automatically) to orient it to "Idle" animation's original orientation. This is something I am trying to avoid.
    I don't want to use a script to turn the character around because I would like to take advantage of the animation's variable speed of turning around (so the character turns based on the variable speed of the turning animation).

    I am making a 3D platformer (only left and right movement) - In other words a 2.5D game and I don't want to flip the character to turn it around - I want to animate the turning so it looks more realistic.

    Thanks,
    Hannes.
     
  2. hannes_unity965

    hannes_unity965

    Joined:
    Sep 2, 2019
    Posts:
    9
    It turns out that..
    Motion > Root Motion Node: <Root Transform>
    ..
    set the angular velocity to zero.

    And when I set:
    Motion > Root Motion Node: <None>
    ..
    then the character was rotated, but not by 180 degrees (even though the animation had 180 degree rotation)

    The amount of rotation that comes from "Apply Root Motion" animator setting depends on the "Project Settings > Time > Fixed Timestep" value. When lowering the value Unity turns the game object more precisely.

    However lowering the Fixed Timestep asks more resources from the CPU. So it seems to me that it is impossible to rotate a game object precisely using the Unity's root motion.

    I am thus abandoning this line of questioning and posting a new question to the forum, asking if there is a way to rotate a game object with root motion precisely, or is it impossible.
     
  3. hannes_unity965

    hannes_unity965

    Joined:
    Sep 2, 2019
    Posts:
    9
    Slight update.

    It turns out the animation I was using doesn't actually turn 180 degrees after all.

    >facepalm<

    I got a slight rotational gain when turning on
    • "Rigidbody > Interpolate: Interpolate".
    But Unity really did a pretty good job getting the correct rotation out of the animation when setting:
    • "Animator > Update Mode: Animate Physics"
    I am guessing this is slightly more costly on performance than just using a script to rotate your character 180 degrees.
     
  4. Blan3X1

    Blan3X1

    Joined:
    May 29, 2019
    Posts:
    28

    Did you achieve it?
    I want to do it too!