Search Unity

Baking clip transform offsets to clip

Discussion in 'Timeline' started by AcidArrow, Jan 9, 2020.

  1. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,792
    Is there an easy way to "bake" clip transform offset to their clip?

    By "bake" I mean, zero the transform offsets and apply the values to the clip so that the clip visually remains the same.

    I'm trying to find a way to do this for a while now but I'm not having any luck. It feels like basic functionality that should be there, but maybe it isn't?
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You could do it with Unity Recorder. You can also edit the animations clip to add the offsets (manually bake), and then uncheck the 'Remove Start Offset' button in on the animation track clip in Timeline.
     
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,792
    Will doing it with the Unity Recorder result in the same amount of keyframes, or will it generate a keyframe for every frame (which I assume it's going to do, which is no good for what I want).

    Imagine a camera animation clip where it has 20 keyframes in the span of 5 seconds. -> Recorder will result in a ton of keyframes, making the clip hard to further edit (unless I'm wrong about the recorder) and 20 keyframes is more than I'm willing to do completely manually (especially considering there are multiple clips I want to do this for).

    The solution is actually to write a tool that edits the playable/clips and applies an obliterates the offsets, but I was hoping there was an easier solution.
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,792
    Actually...

    I am missing something probably again.

    A. These are the recorded clip values:
    clipkeyframe.png

    B: This is the clip offset: (track has no offset)
    offsets.png

    C: This is the final actual position in the scene:
    finalresult.png

    I assumed A+B = C or something like that, but I utterly fail to see what kind of process I would have to do to A and B to result to C.
     
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,792
    So, I *got it*. It's like Clip Transform Offsets is the parent, and then the actual clip is the "child" and the values are in local space. Which...

    I...

    I want a simple tool to create cutscenes. I want to able to say, "you know, at this frame, I want the camera to be at a 45 degree angle". But I can't.

    This tool isn't it. It also wasn't it two years ago, and it probably won't be in 2 extra years.

    The only thing I pity is the amount work I put into creating actual cutscenes with Timeline, that I will now have to re-create from scratch, because I once again bought into the Unity dream.

    I cannot work with this. Maybe other people can, I can't.
     
  6. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Yes. The clip values that are recording are relative to the initial transform of the gameObject. The transform is captured as the offsets.

    It's recommended to reset the transform before recording. The values will be one-to-one with what is captured. There is also warning that is produced to inform about this.
     
  7. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,792
    It is recommended, but it's also useless.

    As far as I can tell there is no way to keep the offsets to 0 past the first clip, so I don't understand what the warning would warn me against (I haven't seen such a warning like ever by the way).

    See, if I reset the transform first and then record a clip, everything is fine:
    timeline1.png
    timeline2.png

    NOW, I want to record another clip... What do I do? I click record, move the camera a bit. The resulting clip looks like this:
    timeline3.png

    What would be the intended workflow to keep the offsets to 0? As far as I can tell there isn't one. It's simply impossible.

    Or am I missing something?
     
  8. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,792
    I spent the weekend trying to find a way to keep everything with zero offsets. I don't think it's possible.

    I would love to be corrected.
     
  9. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Doing it with subsequent clips is definitely not an ideal workflow.

    You would need to
    - turn off extrapolation on the previous clip - this stops timeline from modifying the position outside of the first clip
    - make sure the playhead is at the first keyframe of the clip you want to create
    - reset the transform
    - enable recording
    - put in the value you want.

    Although baking the offsets into a clip seems like an operation we should support. It is something that can be scripted. Maybe other users have scripted this, and maybe has shared it somewhere? I'm not aware of anything offhand, but definitely a useful utility.