Search Unity

Cinemachine brain keeps showing me timeline vcams

Discussion in 'Cinemachine' started by jin-archipin, Feb 5, 2020.

  1. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    Hi I'm not a native English speaker, so sorry for my bad English.

    I put many vcam tracks in one timeline as an intro cutscene, and made a skip button.
    The skip button just finds the playable director and stop it. so the cinemachine brain can show me another vcam. However even the timeline stopped, it keeps showing me the sequence of vcams in the timeline and after all the vcams finished, then it shows me the original vcam. I tried to make the priority of original vcam higher than vcams in the timeline, but it doesn't work. How can I get out of the sequence of vcams in STOPPED timeline?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    How do you stop the timeline?
     
  3. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    It still shows the vcams in timeline even though I deactivated all of them....!!
     
  4. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    just GetComponent<PlayableDirector>().Stop()

    Code (CSharp):
    1.         public void StopActingScene()
    2.         {
    3.             var director = GetComponent<PlayableDirector>();
    4.             director.Stop();
    5.             director.playableAsset = default;
    6.  
    7.             var cams = GameObject.Find("ActingCams").GetComponentsInChildren<CinemachineVirtualCamera>();
    8.             foreach (var cam in cams)
    9.             {
    10.                 if (cam.gameObject.name.Contains("Intro"))
    11.                     cam.gameObject.SetActive(false);
    12.             }
    13.         }
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Deactivating the vcams won't help, nor will adjusting the priorities. Timeline overrides all.

    I can't check this until tomorrow, but I'm wondering if Stop() cleans up properly. Maybe setting playableAsset = default is not such a good idea, because it prevents timeline from cleaning up?

    Instead of calling Stop(), can you fast-forward the time, so that the timeline ends cleanly?
     
  6. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    I tried that line because Stop() doesn't work for cinemachine track. I tried below code and it ends the timeline except cinemachine track.

    Code (CSharp):
    1.         public void StopActingScene()
    2.         {
    3.             var director = GetComponent<PlayableDirector>();
    4.             director.time = director.playableAsset.duration;
    5.         }
     
  7. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    I found a disgusting workaround.

    Code (CSharp):
    1.         public void StopActingScene()
    2.         {
    3.             var director = GetComponent<PlayableDirector>();
    4.             director.time = director.playableAsset.duration;
    5.  
    6.             // TODO: This code is so dumb and destroying my brain, too.
    7.             var brain = CameraManager.Main.GetComponent<CinemachineBrain>();
    8.             DestroyImmediate(brain);
    9.             CameraManager.Main.gameObject.AddComponent<CinemachineBrain>();
    10.         }
    It works for now, but I hate it.

    EDIT: I'm currently using cinmachine 2.3.4, and I hope it is fixed in 2.5.0. I'm want to migrate right now, but some transitions are not working like before so I need extra time. I'm thinking of migrating in next month, so I'll see if it keeps showing finished timeline then.
     
    Last edited: Feb 5, 2020
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    oh! that is a terrible hack :(
    This should be working without it.
    Would you make a small repro project that shows this problem and send it to me?
     
  9. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    I'm not sure I have time for that now, but I'll do in a month.
     
  10. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    Oh S*** I found my mistake while doing other stuff.
    The timeline was somehow playing in two different director, and the brain was showing the other director's vcam.

    Sorry for confusing mistake.
     
    Gregoryl likes this.
  11. JeffG

    JeffG

    Joined:
    Oct 21, 2013
    Posts:
    85
    This happened to me.

    I had a Virt Cam that is activated in the timeline. If I call stop, the camera remains active. (Using Unity 2018.4 probably 2 release behind) I resorted to turning them off via code. FWIW
     
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    @jin-archipin maybe you can say something about what your error was?
     
  13. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    I put the timeline in a random object to test, and played in another object. I forgot to remove the timeline from testing object before save the scene, so the timeline was played on awake. Unfortunately, I was playing the timeline in the right object when the game start, so two identical timelines were playing together in different objects.
     
    Gregoryl likes this.