Search Unity

Bug Timeline vcam clip blending issue

Discussion in 'Cinemachine' started by Chris-V, Apr 27, 2023.

  1. Chris-V

    Chris-V

    Joined:
    Jul 29, 2015
    Posts:
    8
    Having a strange issue with Cinemachine tracks in Timeline when trying to blend vcam clips that are created from scripts. As shown in the video, the timeline only seems to respect the blend once the track is fully visible in the Timeline editor view.



    I have the track under a group track, and the blend only kicks in once I expand the group track to view the Cinemachine track. I see the same behavior if the track isn't in a group track, but if I just never open the Timeline editor window, so it's a visibility thing, not a group track thing. Once the track becomes visible, the blend works from then on, even if the track is no longer visible (i.e., I collapse the group track or close the Timeline window).

    It seems as if there is some state change resulting from the track becoming visible in the editor window. This holds true in player builds: the timeline never plays correctly since the editor window doesn't exist.

    A few things worthy of note:
    * I am creating all clips in the timeline from code.
    * In order to do what I need, I am using: Director.SetReferenceValue(shot.VirtualCamera.exposedName, cameraObj.GetComponent<CinemachineVirtualCamera>());
    * This is a fairly complex project so it's possible there are other factors influencing things here. I can try to make a simplified version, but I wanted to see if something was obvious to others before doing so.

    My primary question is, what is the Editor doing when the track becomes visible that would influence how the clips blend from that point forward? That seems to be the only thing required in this scenario to have the clips begin to blend correctly.

    Unity version: 2023.1.0b12
    Cinemachine version: 2.9.5
    Timeline version: 1.8.2
     
  2. grahamsaulnier

    grahamsaulnier

    Unity Technologies

    Joined:
    Apr 10, 2018
    Posts:
    18
    When are you calling `Director.SetReferenceValue`? I don't see anything peculiar in Cinemachine's Shot ClipEditor that would affect the playable graph. But I'm guessing that the way you bind your virtual cameras to the game objects isn't triggering the graph to rebuild so the blends aren't generated. But opening the Timeline Window (with those tracks in view) is triggering the rebuild.
     
    Gregoryl likes this.
  3. Chris-V

    Chris-V

    Joined:
    Jul 29, 2015
    Posts:
    8
    I am calling SetReferenceValue in scripts that build up the timeline from code. After all clips are created I manually call RebuildGraph on the PlayableDirector of the timeline to rebuild the graph. This has always worked to rebuild everything properly, but the blends seem not to work.

    Your suggestion was helpful though, in that I just confirmed that it's not anything specific to Cinemachine. Those Cinemachine clips just happened to be the only blends I was doing. It seems this is true for all blends. I just tried it with an audio track and the same thing happens: the audio from the second clip immediately starts playing at the same volume over the previous clip until I reveal the track in the editor, at which point they crossfade. However, if I only reveal the audio track, and not the Cinemachine track, the Cinemachine clips continue not to blend, until that track is revealed.

    Should calling RebuildGraph manually cause the blends to be calculated? Is there some other way to force the blends to be rebuilt from code?
     
  4. grahamsaulnier

    grahamsaulnier

    Unity Technologies

    Joined:
    Apr 10, 2018
    Posts:
    18
    @julienb answered a similar question not too long ago here

    When generating your clips, you also need to manually calculate the blend values.
     
  5. Chris-V

    Chris-V

    Joined:
    Jul 29, 2015
    Posts:
    8
    Ah! Thank you for the reference. Searched for a while before posting but didn't find that post. Yes this must be the problem.

    As the other poster mentions, I wasn't aware this needed to be done manually either. Since the editor is doing this automatically upon opening the Timeline view, could that be incorporated into an API call? Seems like it would be a useful thing to have.

    Thanks for the help.