1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Cinemachine;
- public class ChangeCamera : MonoBehaviour
- {
- private int _priority = 0;
- // Start is called before the first frame update
- void Start()
- {
-
- }
- private void OnTriggerEnter(Collider other)
- {
- Role role = other.gameObject.GetComponent<Role>();
- if(!role || !role.IsTeamLeader)
- {
- return;
- }
- CinemachineVirtualCamera cine = this.GetComponent<CinemachineVirtualCamera>();
- if(this._priority >= 100)
- {
- return;
- }
- this._priority = cine.Priority;
- cine.Priority += 100;
- }
- private void OnTriggerExit(Collider other)
- {
- Role role = other.gameObject.GetComponent<Role>();
- if (!role || !role.IsTeamLeader)
- {
- return;
- }
- CinemachineVirtualCamera cine = this.GetComponent<CinemachineVirtualCamera>();
- cine.Priority = this._priority;
- }
- }
|