SimpleTools/Tools/Cinemachine/CMCameraTrigger.cs
Gerard Gascón 0e8b8b1835
Reworked the dialogue system
Now the dialogue can use tags to add special effects
Reorganized project structure, updating may require adding some using statements
2022-09-15 17:27:28 +02:00

40 lines
No EOL
865 B
C#

using UnityEngine;
using Cinemachine;
namespace SimpleTools.Cinemachine {
public class CMCameraTrigger : MonoBehaviour {
CinemachineVirtualCamera vcam;
void Awake() {
vcam = GetComponentInChildren<CinemachineVirtualCamera>(true);
vcam.gameObject.SetActive(false);
}
#region 3D
void OnTriggerEnter(Collider col) {
if (col.CompareTag("Player")) {
vcam.gameObject.SetActive(true);
}
}
void OnTriggerExit(Collider col) {
if (col.CompareTag("Player")) {
vcam.gameObject.SetActive(true);
}
}
#endregion
#region 2D
void OnTriggerEnter2D(Collider2D col) {
if (col.CompareTag("Player")) {
vcam.gameObject.SetActive(true);
}
}
void OnTriggerExit2D(Collider2D col) {
if (col.CompareTag("Player")) {
vcam.gameObject.SetActive(false);
}
}
#endregion
}
}