I am trying to call certain methods using timeline and custom markers (Notifications), as demonstrated here.
The goal is that each marker notifies the manager script to start a new wave of enemies that have to be defeated by the player before moving on. For that matter, I am using _playable.Pause() (where _playable is a PlayableDirector component) when a marker is reached and the corresponding notification received. Everything works to this point, but after beating all enemies I call _playable.Resume() and the marker’s notification is pushed again, causing an infinite loop of pausing > spawning enemies > resuming > pausing…
As a test, I’ve tried to play the timeline continuously (without calling the Pause() method) and notifications are only pushed once. But once I opt for the pausing approach, they are pushed indefinitely, even after the current time is beyond the notification marker’s time.
Any idea what’s going on and why previous notifications keep being pushed after a Timeline is resumed?
Try pausing the director only at the end of the frame, not in the notification itself. In LateUpdate maybe.
The problem you get is probably because the PlayableDirector hasn’t had a chance to finish the frame, and when you unpause it, it still thinks it’s executing the frame where it was paused.
By pausing and unpausing it outside of its evaluation, it should have the opportunity to advance time and evaluate a different frame
It does advance a little after unpausing, but the previous notification keeps being pushed.
So, the notification marker is in frame 120.
It is received and paused at 120,5.
After everything is done, it resumes and plays until 121,4. Pauses again, due to the notification being pushed.
It keeps resuming/pausing every 0.5 frames or so.
How can a notification keep being pushed past the frame where the marker is?