Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Timeline playables playing instantly?

Discussion in 'Timeline' started by BubyMB, Jan 8, 2018.

  1. BubyMB

    BubyMB

    Joined:
    Jun 6, 2016
    Posts:
    140
    Hey guys, I just got into timeline and i downloaded the default playables pack and changed it so it turned on lights on my car, but the playable executes instantly no matter where on the timeline
     
  2. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170
    Are you using activation track? If yes, is that object disabled before you start?
     
  3. BubyMB

    BubyMB

    Joined:
    Jun 6, 2016
    Posts:
    140
    Yes, I am using the activation track and if you mean the lights are disabled, yes.
     
  4. thierry_unity

    thierry_unity

    Joined:
    Jun 10, 2015
    Posts:
    187
    Hi!
    What version of unity are you using? Do you mind posting a small repro of your issue here or by opening a bug with the bug reporter so we could investigate?
    thanks!
     
  5. BubyMB

    BubyMB

    Joined:
    Jun 6, 2016
    Posts:
    140
    Using Unity 2017.3.0f3
    Okay so i am using two scripts; 'NormLightStartBehaviour' (The timeline behaviour) and 'CarControl'.
    Car control changes the material of the lights from one without an emitter to one with.
    Code (csharp):
    1.  
    2.     public void turnOn(string name){
    3.         if (name == "norm") {
    4.             normIsOn = !normIsOn;
    5.         }
    6.         else if (name == "turn") {
    7.             turnIsOn = !turnIsOn;
    8.             Blinker.Play ();
    9.         }
    10.         else if (name == "reverse") {
    11.             revIsOn = !revIsOn;
    12.         }
    13.     }
    14.     void Update(){
    15.         if (!revIsOn) {
    16.             foreach (GameObject go in Lights_Reverse) {
    17.                 go.gameObject.GetComponent<Renderer> ().material = reverse [1];
    18.             }
    19.         } else {
    20.             foreach (GameObject go in Lights_Reverse) {
    21.                 go.gameObject.GetComponent<Renderer> ().material = reverse [0];
    22.             }
    23.         }
    24. }
    25.  
    ^^ In that case i am just showing Lights_Reverse, 'norm' and 'turn' have the same activation method.

    Code (csharp):
    1.  
    2. using System;
    3. using UnityEngine;
    4. using UnityEngine.Playables;
    5. using UnityEngine.Timeline;
    6.  
    7. [Serializable]
    8. public class NormLightStartBehaviour : PlayableBehaviour{
    9.  
    10.     public string name;
    11.  
    12.     public override void OnGraphStart (Playable playable)
    13.     {
    14.         GameObject.Find("Lamborghini_Aventador").GetComponent<CarControl> ().turnOn (name);
    15.     }
    16. }
    17.  
    18.  
    This is the NormLightStartBehaviour which i got from the Default playables pack.
    Before the scene is played, by default the lights are off, and the 'CarCaontrol' script automatically turns them off if the bool is false so I have marked that out of the equation.

    So no matter what, the light will turn on as soon as I hit play.
    and i know its a problem with 'NormLightStartBehaviour' because, for example;
    If I type 'norm' to turn on the normal lights it will turn on straight away, but if i change it to 'reverse' the normal lights won't turn on and reverse lights will.

    Not sure if this is a bug or me doing something wrong. Thanks.

    Full 'CarControl' script
    https://gist.github.com/Bubytech/ac4bfb9f3b72dbecb0f20e27ff2c4e07
     
    Last edited: Jan 9, 2018
  6. Carwashh

    Carwashh

    Joined:
    Jul 28, 2012
    Posts:
    760
    OnGraphStart is called when the timeline starts playing. You've got your lights turning on in OnGraphStart.
     
  7. BubyMB

    BubyMB

    Joined:
    Jun 6, 2016
    Posts:
    140
    Ah alright cheers, whats the proper function to use?
     
  8. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    OnBehaviourPlay()