I’ve been looking around for the answer to the same question and I can’t find anything. The docs aren’t very helpful without code examples. I’ve tried something like GetComponent<PlayableDirector>()
on the gameobject but it keeps saying "PlayableDirector" is not part of the current context
. How can I get this component and detect if the timeline has finished playing the cutscene?
After watching one of the timeline scripting video’s, the way to access a PlayableDirector component in a gameobject is to use the UnityEngine.Playable
library. So to check if the timeline is playing I’d have to do the following:
using System.Collections;
using UnityEngine;
using UnityEngine.Playable;
public class cutscene1 : MonoBehavior{
PlayableDirector director;
bool playing = false;
void Awake(){
director = GameObject.Find("cutscene1GameObject").GetComponent<PlayableDirector>();
}
void Update(){
if(director.state != PlayState.Playing){
playing = false;
}else{
playing = true;
}
}
}