Search Unity

Interpret AnimationClip Values as Absolute - Not Relative

Discussion in 'Timeline' started by f0ff886f, Apr 27, 2019.

  1. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    Apologies if this is covered in one of the many root motion style questions but I'm still not entirely clear on what root motion is and if this is what I want or not.

    My issue: I had created animations on the old Animation component, and when I would preview the animation my object would snap to the *exact position and rotation* described in the animation curve.

    Now, when I am trying the same animationclip added to a Timeline, it seems to animate the rotation as just an offset rather than absolute value. So I have to tween my object's rotation to the values of the first frame of the animationclip in a script, which is something I was trying to get away from.

    Is it possible to get the animation clip to play back exact rotation values, and then I can use the Ease In Duration in order to get a smooth transition from current rotation to the expected rotation in the clip?

    Thanks!
     
  2. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    It seems like I would want the "Apply Transform Offsets" option, but that puts my object in some spot in the world I cannot see (I can't figure out where it because I can't see the inspector of the object while previewing the Timeline, and if I lock the inspector then my Transform component has nothing visible at all in it).

    Simple ask is: how can I mimic the behaviour of the Animation component on an object with a specific animation clip? Apply Transform Offsets doesn't do it, it moves my object to some magical spot, Apply Scene Offsets animates everything as an offset from the current position. Am I missing something? I can't apply the inverse in the track/clip offsets because I don't know from what the object's rotation will be when the animation starts.
     
  3. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Like you are trying, apply transform offsets is the correct mode and you should turn off the 'apply root motion' on the animator. You should then be able to ease-in the value, and ease-in to the absolute value in your clip.

    Does your animation only have rotation values and no translation? That may be part of the issue here. Animating one normally means the other gets written. You may need to set the translation offset on the track to the exact location you need. I admit I don't understand how the transform has nothing visible it, maybe an image would be helpful?
     
  4. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    Spoiler: by being meticulous in trying things, I got this working, thanks to your confirmation that I should focus on "apply transform offsets".

    Thank you for the quick reply (on a Sunday!). I'll try to be completely clear with images as to not leave you guessing :)

    First off, here is my Animator component on the "PlayerFPC" game object (I'm unclear about what that first "Root position" info box means):
    upload_2019-4-28_15-4-58.png

    This is what the animation window looks like for the clip I'm having trouble with (as you can see, it does have position and rotation, and position is also very broken and its easier to inspect, so lets focus on position):
    upload_2019-4-28_15-6-10.png

    And this is what I mean by the Transform (mind you I use TransformPro) being empty when I lock the inspector panel to my object being animated (PlayerFPC) and then try to see where it is animating the player to when I am completely in magical somewhere land:

    upload_2019-4-28_15-8-15.png

    However, I was able to see values when viewing the debug mode inspector (sorry, I didn't try this last night), but the rotation is given as a quat so lets look at the position instead:
    upload_2019-4-28_15-10-24.png

    For the record, the base local position of Frame 0 should be (10.53379, 3.47571, -7.478381).

    The end of the mystery is at hand:
    Now, for all you folks at home, here's where I made a mistake yesterday and today: I always focused on one of the two values for the offset (I thought positions are obviously broken, so I add a position offset to the clip). But for some stupid reason, I never put both offsets in (position AND rotation).

    As soon as I put both offsets in (as collected from the first frame of the old animation), the clip started to work!!!!

    So this is solved, thank you, thank you very very very much @seant_unity .

    I do have one related question ;) What the heck do these buttons do?
    upload_2019-4-28_15-30-24.png

    Thank you again.
     
  5. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    That's great! I'm glad you solved it, and thanks for posting pics - the non-visible transform really threw me for a loop.

    To answer your question, those buttons let you change the offsets using gizmos in the scene view, instead of typing them in manually.
     
    f0ff886f likes this.
  6. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Actually, you also may want to try using the 'Remove Start Offset' field on the timeline clip. That makes the clip play all position/rotations relative to the first key. Removing that may remove the need to use the offsets altogether.
     
    f0ff886f likes this.
  7. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    Holy guacamole, you're right. Unchecking the "Remove Start Offset" bool on the clip completely removes the need to manually set anything in the offsets!

    So, the perfect setup automatically blending the current position and rotation of an object to a predefined animation clip with Timelines is:

    Make sure your Animation Track is set to Apply Transform Offsets:
    upload_2019-4-28_16-34-39.png

    Make sure your clip has an "Ease In Duration" and that Remove Start Offset is unchecked:
    upload_2019-4-28_16-35-20.png

    The clip should look like this on the timeline to reflect the Ease In:
    upload_2019-4-28_16-35-38.png

    Now we're talking. Thanks again.
     
    Last edited: Apr 29, 2019
    seant_unity likes this.