I wanted a fixed camera but with 4 different positions that I can jump between. I’ve so far set it up to turn 90 degrees around the player with Q and E buttons. Rather than using the prefabs I went back to the one we made since I didn’t feel the need to have much from the others. I’ll probably go back later and check how to do the no clipping.
void Update()
{
CameraKeyRotate();
}
private void CameraKeyRotate()
{
if (Input.GetKeyDown(KeyCode.E))
{
StartCoroutine(RotateCamera(Vector3.up * 90, 0.5f));
}
else if (Input.GetKeyDown(KeyCode.Q))
{
StartCoroutine(RotateCamera(Vector3.down * 90, 0.5f));
}
}
IEnumerator RotateCamera(Vector3 byAngles, float inTime)
{
var fromAngle = transform.rotation;
var toAngle = Quaternion.Euler(transform.eulerAngles + byAngles);
for (var t = 0f; t < 1; t += Time.deltaTime / inTime)
{
transform.rotation = Quaternion.Lerp(fromAngle, toAngle, t);
yield return null;
}
}