Deleted the Test File
1 parent b9ba16e commit e68242248b6b91b7bb246906a8bf7906aff4e90e
@Rackday Rackday authored on 20 Jul 2024
Showing 1 changed file
View
49
Assets/Scripts/TESTETT.cs 100644 → 0
using
System.Collections;
using
System.Collections.Generic;
using
UnityEngine;
public
class
CameraBehaviour
:
MonoBehaviour
{
[
SerializeField
]
private
Transform followTarget;
[
SerializeField
]
private
float
rotationSpeed =
10f
;
[
SerializeField
]
private
float
bottomClamp =
-40f
;
[
SerializeField
]
private
float
topClamp =
70f
;
private
float
cinemachineTargetPitch;
private
float
cinemachineTargetYaw;
// Start is called before the first frame update
void
Start
()
{
}
// Update is called once per frame
void
LateUpdate
()
{
CameraRotation();
}
private
float
GetMouseInput
(
string
axis
)
=> Input.GetAxis(axis) * rotationSpeed * Time.deltaTime;
private
void
CameraRotation
()
{
float
mouseX = GetMouseInput(
"Mouse X"
);
float
mouseY = GetMouseInput(
"Mouse Y"
);
cinemachineTargetPitch = UpdateRotation(cinemachineTargetPitch, mouseY, bottomClamp, topClamp,
true
);
cinemachineTargetYaw = UpdateRotation(cinemachineTargetYaw, mouseX,
float
.MinValue,
float
.MaxValue,
false
);
ApplyRotations(cinemachineTargetPitch, cinemachineTargetYaw);
}
private
void
ApplyRotations
(
float
pitch,
float
yaw
)
=> followTarget.rotation = Quaternion.Euler(pitch, yaw, followTarget.eulerAngles.x);
private
float
UpdateRotation
(
float
currentRotation,
float
input,
float
min,
float
max,
bool
isXAxis
)
{
currentRotation += isXAxis ? -input : input;
return
Mathf.Clamp(currentRotation, min, max);
}
}