-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSwitchCamera.cs
123 lines (88 loc) · 3.37 KB
/
SwitchCamera.cs
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
public class SwitchCamera : MonoBehaviour
{
[Header("Camera to Assign")]
public GameObject AimCam;
public GameObject AimCanvas;
public GameObject ThirdPersonCam;
public GameObject ThirdPersonCanvas;
public PlayerScript player;
[Header("Camera Animator")]
public Animator animator;
private void Update()
{
if(player.mobileInputs == true)
{
if (CrossPlatformInputManager.GetButton("Aim") && player.currentPlayerSpeed >0)
{
animator.SetBool("Idle", false);
animator.SetBool("IdleAim", true);
animator.SetBool("AimWalk", true);
animator.SetBool("Walk", true);
ThirdPersonCam.SetActive(false);
ThirdPersonCanvas.SetActive(false);
AimCam.SetActive(true);
AimCanvas.SetActive(true);
}
else if (CrossPlatformInputManager.GetButton("Aim"))
{
animator.SetBool("Idle", false);
animator.SetBool("IdleAim", true);
animator.SetBool("AimWalk", false);
animator.SetBool("Walk", false);
ThirdPersonCam.SetActive(false);
ThirdPersonCanvas.SetActive(false);
AimCam.SetActive(true);
AimCanvas.SetActive(true);
}
else
{
animator.SetBool("Idle", true);
animator.SetBool("IdleAim", false);
animator.SetBool("AimWalk", false);
ThirdPersonCam.SetActive(true);
ThirdPersonCanvas.SetActive(true);
AimCam.SetActive(false);
AimCanvas.SetActive(false);
}
}
else
{
if (Input.GetButton("Fire2") && Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
{
animator.SetBool("Idle", false);
animator.SetBool("IdleAim", true);
animator.SetBool("AimWalk", true);
animator.SetBool("Walk", true);
ThirdPersonCam.SetActive(false);
ThirdPersonCanvas.SetActive(false);
AimCam.SetActive(true);
AimCanvas.SetActive(true);
}
else if (Input.GetButton("Fire2"))
{
animator.SetBool("Idle", false);
animator.SetBool("IdleAim", true);
animator.SetBool("AimWalk", false);
animator.SetBool("Walk", false);
ThirdPersonCam.SetActive(false);
ThirdPersonCanvas.SetActive(false);
AimCam.SetActive(true);
AimCanvas.SetActive(true);
}
else
{
animator.SetBool("Idle", true);
animator.SetBool("IdleAim", false);
animator.SetBool("AimWalk", false);
ThirdPersonCam.SetActive(true);
ThirdPersonCanvas.SetActive(true);
AimCam.SetActive(false);
AimCanvas.SetActive(false);
}
}
}
}