Page 1 of 1

Timeline Not Pausing On Time

Posted: Sat Apr 08, 2023 4:18 pm
by PayasoPrince
Hello,

Something I noticed is that when you set a Timeline's speed to 0 with a conversation clip, it does not pause the timeline immediately. (Example: Timeline(speed, TimelineManager, 0);

Image

After some testing, if you were to pause the Timeline using a Signal Emitter that calls a method that pauses the Timeline like this, the same delay before the pause happens:

Code: Select all

public void StopTimeline()
    {
        director.playableGraph.GetRootPlayable(0).SetSpeed(0);
        StartCoroutine(GameEngine.Instance.DialogueManager.TriggerCutsceneDialogue(currentCutsceneDialogue));
    }
So, it looks like this is a fault with Timeline not being able to pause immediately.
However, this is a problem with games that need to pause for dialogue/player input. Depending on the framerate the game is running at, there are varied results of when the Timeline will actually pause. So, animations that are supposed to happen after the pause, might start happening before the pause depending on how long it takes the Timeline to pause.

A very brittle workaround is simply adding a bit of padding to give the Timeline time to pause, but that comes with its own issues. If the machine is high performance, It will pause a bit after its told to. Then there will be a brief wait time where nothing happens. There's also no guarantee that the padding will be long enough for low end machines to pause the Timeline in time.

So, I say all of that to ask this -
Is there an elegant way to consistently stop a Timeline so that you can display dialogue/wait for player input, that also guarantees that the pause won't happen too late and show animations that shouldn't be happening yet?

Thank you

Re: Timeline Not Pausing On Time

Posted: Sat Apr 08, 2023 5:16 pm
by Tony Li
Timeline updates its position based on Time.time, which won't always line up with an exact frame (e.g, Time.frameCount). It may pause one frame later, or even more frames when Time.timeScale is > 1.

There isn't much you can do about this, since it's the way Timeline is designed. Another option is to split your timeline into multiple timelines, and kick them off using Timeline() sequencer commands in dialogue entries.