Created
April 30, 2018 16:59
-
-
Save gekidoslair/a1484ace66a9237aecd76abec4598789 to your computer and use it in GitHub Desktop.
Activate a Unity Timeline from a trigger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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