I have a camera in my scene that I want to rotate around the player. The rotation is done when the camera rotation state is at CameraRotation.Left or CameraRotation.Right and CameraRotation.None indicates that the camera should stop rotating and just follow the player.
I want the camera to rotate around the player and stop after it reaches a specific angle (180 degrees) in the y axis in the CameraRotation.Left or CameraRotation.Right from the position the camera was at the start of the rotation. It would also be helpful if some direction is given on how to edit the SmoothFollow() method so that it follows the player with the camera still rotated.
The problem is I'm not familiar with rotations and not sure whether to use Euler angles or quaternions so any tips would help.
private void LateUpdate()
{
if (GameManager._RotateCamera == CameraRotation.None)
{
SmoothFollow();
}
else if (GameManager._RotateCamera == CameraRotation.Left)
{
transform.RotateAround(player.transform.position, Vector3.up, rotationSpeed * Time.deltaTime);
}
else if (GameManager._RotateCamera == CameraRotation.Right)
{
transform.RotateAround(player.transform.position, Vector3.down, rotationSpeed * Time.deltaTime);
}
}
// Make the Camera follow the player smoothly
private void SmoothFollow()
{
Vector3 desiredPoistion = player.position + offset;
Vector3 smoothedPosition = Vector3.SmoothDamp(transform.position, desiredPoistion, ref velocity, smoothSpeed);
transform.position = smoothedPosition;
transform.LookAt(player.transform);
}
RotateAround
exactly 180 degrees in the time after some function has been called? \$\endgroup\$