Skip to content

Instantly share code, notes, and snippets.

@gekidoslair
Created April 30, 2018 16:59
Show Gist options
  • Save gekidoslair/a1484ace66a9237aecd76abec4598789 to your computer and use it in GitHub Desktop.
Save gekidoslair/a1484ace66a9237aecd76abec4598789 to your computer and use it in GitHub Desktop.
Activate a Unity Timeline from a trigger
using UnityEngine;
using UnityEngine.Playables;
public class GenericTrigger : MonoBehaviour
{
public PlayableDirector timeline;
// Use this for initialization
void Start()
{
timeline = GetComponent<PlayableDirector>();
}
void OnTriggerExit(Collider c)
{
if (c.gameObject.tag == "Player")
{
timeline.Stop();
}
}
void OnTriggerEnter(Collider c)
{
if (c.gameObject.tag == "Player")
{
timeline.Play();
}
}
}
@jaaacccobdev
Copy link

when my player walks to the trigger nothing happens can you help please

@gekidoslair
Copy link
Author

Hopefully you figured it out - you need a collider set to 'trigger' and a Rigidbody on either the object that has the trigger script OR the player - basically OnTrigger events are only triggered by RigidBodies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment