Search Unity

Playable.OnGraphStop called when pausing Timeline. Breaks CinemachineMixer

Discussion in 'Timeline' started by AlienMe, Jul 19, 2017.

  1. AlienMe

    AlienMe

    Joined:
    Sep 16, 2014
    Posts:
    93
    We are using Timeline to create cutscenes and tutorials. When we wait for player input (e.g. showing a dialog), we pause the PlayableDirector. Once the player is done, we resume the Timeline.

    We expected that when pausing the timeline, the camera would stay in its current place (as per the Cinemachine Track, and current CinemachineShot).

    The issue we are seeing is that when we call PlayerDirector.Pause, instead of Cinemachine keeping the active Virtual Camera it jumps to use a 'random' camera.

    We tracked this down to Timeline calling OnGraphStop on each Playable when pausing the timeline. When this happens CinemachineMixer assumes the Timeline fully stopped and releases any overrides it has on the CinemachineBrain.

    I couldn't find a way to tell when the Timeline was paused vs. stopped.

    The PlayableDirector has 2 states (Playing or Paused), the Graph has a bool IsPlaying.

    It would be nice if the 3 states (Stopped, Playing, Paused) were clearly defined and accessible.
     
  2. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    I too have this issue, as you mention it now. When paused or resumed the camera jumps between different cameras.
    Possibly a cinemachine issue which is not implemented the onPause behaviour.
     
  3. AlienMe

    AlienMe

    Joined:
    Sep 16, 2014
    Posts:
    93
    Not quite, the issue is not with Cinemachine. It's Timeline calling Playable.OnGraphStop when the timeline is paused.
     
  4. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    You are correct. Both OnBehaviourPause and OnGraphStop functions are called when either paued or stopped :confused:



    Code (CSharp):
    1. public override void OnBehaviourPause(Playable playable, FrameData info)
    2.     {
    3.         Debug.Log ("Paused for break");
    4.     }
    5.  
    6.     public override void OnGraphStop(Playable playable)
    7.     {
    8.         Debug.Log ("Stopped! Damn it!");
    9.     }
    Code (CSharp):
    1.  
    2.  
    3. PlayableDirector myPlayDirector;
    4.  
    5.  
    6. void Start () {
    7.         myPlayDirector = GetComponent<PlayableDirector>();
    8. }
    9.  
    10. void Update () {
    11.      
    12.         if (Input.GetKeyDown (KeyCode.Z))
    13.             myPlayDirector.Play ();
    14.  
    15.         if (Input.GetKeyDown (KeyCode.X))
    16.             myPlayDirector.Stop ();  
    17.  
    18.         if (Input.GetKeyDown (KeyCode.C))
    19.             myPlayDirector.Pause ();
    20.  
    21.         if (Input.GetKeyDown (KeyCode.V))
    22.             myPlayDirector.Resume ();
    23.     }
    24.  
     
    Last edited: Jul 20, 2017
  5. Firemaw

    Firemaw

    Joined:
    Aug 24, 2015
    Posts:
    63