Advertisement
SizilStank

Untitled

Feb 1st, 2024
932
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Cinemachine;
  5. using UnityEditor;
  6.  
  7. public class vCmasSwitchingOnCollision : MonoBehaviour
  8. {
  9.     [SerializeField] private CinemachineVirtualCameraBase[] _vCams;
  10.     [SerializeField] private int _vCamsIndex = 0;
  11.     [SerializeField] private GameObject _player;
  12.  
  13.     private CinemachineVirtualCameraBase _cam;
  14.  
  15.     // Start is called before the first frame update
  16.     void Start()
  17.     {
  18.         _cam = GetComponent<CinemachineVirtualCameraBase>();
  19.  
  20.         EventManager.CollisionEvent01 += SwitchVcam;
  21.     }
  22.  
  23.     private void SwitchVcam()
  24.     {
  25.         _vCams[0].gameObject.SetActive(true);
  26.     }
  27.  
  28.     //How can we Subcribe this event like we did EventManager.CollisionEvent01 += SwitchVcam;
  29.     private void OnTriggerEnter(Collider other)
  30.     {
  31.         if (other.gameObject.CompareTag("Player"))
  32.         {
  33.             Debug.Log("!!!!" + other.gameObject.name);
  34.         }
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement