How to blend between the current state of my camera to Unity Timeline

Hey everyone, I have a noob question about timeline in Unity.

I want to zoom smoothly on one object of my 2d game using timeline for a game tutorial. Problem is that I don’t know the real camera zoom (Orthographic size property) before launching the game (screen dependant) so my timeline first keyframe is kind of wrong (I hardcoded a zoom value).

Is there some features that would allow me to take the current dynamic state of my camera as first keyframe without hardcode value ? I want my camera to smoothly blend from the game current state to the timeline state.

I tried to remove the first keyframe but it does not work as expected and the timeline jump immediately to the next keyframe without transiting at all.

The Cinemachine package might be able to help with that. I haven’t used it or Timeline much, but when I did they worked pretty well together.

Otherwise you could probably have the Timeline animate a custom value in your script which you then use to interpolate the zoom value yourself.

I have the PlayableDirector in the script but I don’t know how to reach the first keyframe of the timeline track from it. Do you have a code example for doing this ?

You can’t access the keyframes at runtime, but if the Timeline animates a value in your script you can obviously access that value and do whatever you want with it.

I don’t understand.

I can ofc access the size value of my camera by script but it does not solve the problem since my timeline offer more than a value change over time. The only way that it could help is if I can override in the track the first keyframe value to continue the animation using this first correct size value.

I found the solution, you need to convert the track into a clip track (right click on the track), remove the first keyframes and play with ease-in duration property in inspector.

2 Likes