Firstborn/Library/PackageCache/com.unity.cinemachine@2.8.9/Samples~/Cinemachine Example Scenes/Scenes/Trigger volumes/GenericTrigger.cs

37 lines
981 B
C#
Raw Normal View History

2023-03-28 13:24:16 -04:00
#if CINEMACHINE_TIMELINE
using UnityEngine;
using UnityEngine.Playables;
namespace Cinemachine.Examples
{
public class GenericTrigger : MonoBehaviour
{
public PlayableDirector timeline;
// Use this for initialization
void Start()
{
timeline = GetComponent<PlayableDirector>();
}
void OnTriggerExit(Collider c)
{
if (c.gameObject.CompareTag("Player"))
{
// Jump to the end of the timeline where the blend happens
// This value (in seconds) needs to be adjusted as needed if the timeline is modified
timeline.time = 27;
}
}
void OnTriggerEnter(Collider c)
{
if (c.gameObject.CompareTag("Player"))
{
timeline.Stop(); // Make sure the timeline is stopped before starting it
timeline.Play();
}
}
}
}
#endif