-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathCamManager.cs
More file actions
45 lines (37 loc) · 1.12 KB
/
CamManager.cs
File metadata and controls
45 lines (37 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
public class CamManager : MonoBehaviour
{
public bool IsCurrentFp = false;
private GameObject _player;
public GameObject FirstPersonCamObj;
public GameObject ThirdPersonCamObj;
private CinemachineVirtualCamera _vCam;
// Update is called once per frame
void Update()
{
if (_player == null)
{
_player = PlayerManager.Players.LocalPlayerGo;
FirstPersonCamObj = _player.transform.Find("FirstPersonCam").gameObject;
_vCam = FirstPersonCamObj.GetComponent<CinemachineVirtualCamera>();
_vCam.Priority = 20;
}
else
{
CamChange();
}
}
private void CamChange()
{
if (PlayerKeyboard.KeyboardInput("Camera", KeyboardInput.CameraViewChange))
{
IsCurrentFp = !IsCurrentFp;
FirstPersonCamObj.SetActive(IsCurrentFp);
ThirdPersonCamObj.SetActive(!IsCurrentFp);
FirstPersonCamObj.transform.rotation = new Quaternion(0,0,0,0);
}
}
}