Abacito
Abacito

Reputation: 151

Timeline doesn't start eventhough it recognises the trigger input

I have a code setup whereby the timeline is suppose to play when a gameobject collides/triggers another gameobject. Unity recognises this trigger(prints out to the console) but the timeline does not play. Here is the code I have

using UnityEngine;
using System.Collections.Generic;
using UnityEngine.Playables;
 
public class GenericTrigger : MonoBehaviour
{
    public PlayableDirector timeline;
 
    // Use this for initialization
    void Start()
    {
        timeline = GetComponent<PlayableDirector>();
    }
 
 
    void OnTriggerExit(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            //timeline.Stop();
        }
    }
 
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            Debug.Log("Trigger Entered");
            Destroy(this.gameObject);
            
            timeline.Play();
        }
    }
}

The reason why the playable director attached to the scripts is "TriggerObject"(the name of the gameobject it is attached) is because that is the only option available for me to click when I clicked the encircled dot next to it.

This is the inspector on the cube that the script is attached to

Upvotes: 0

Views: 40

Answers (0)

Related Questions