How do I play a Playable Director via script?

I am new to the unity forum so if they’re are any issues with my post I am sorry. This post is self-explanatory. Here is what I have:
```csharp
**using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;

public class CameraCutscene : MonoBehaviour
{
public AudioSource levelMusic;
public PlayableAsset cutscene;
public PlayableDirector director;
private Player player;
private bool triggered = false;
private void OnTriggerEnter2D(Collider2D other) {
if (other.tag == “Player”) {
if (!triggered){
print(“triggered!”);
triggered = true;
director.playableAsset = cutscene;
player = other.GetComponent();
levelMusic.enabled = false;
director.Play(cutscene);
director.stopped += (ctx) => {
print($“{cutscene.name} stopped”);
levelMusic.enabled = true;
};
}

    }
}

}**
```

I fixed it! I used my timeline animation used the cinemachine camera but I set my camera to follow my player. so I changed the follow variable in the script and it worked.

1 Like