So, I’m making a script that controls my third person camera over-the-shoulder style. It kinda works similar to what I want, but it have a minor inconvenient: when I rotate too fast or for a long period in the Y axis, the camera loses the player from the view, unless I stop moving the player, which is when the camera returns to its place.
This is my code so far:
[SerializeField]
private Transform target;
private void LateUpdate()
{
transform.position = target.position;
transform.rotation = Quaternion.RotateTowards(transform.rotation, target.rotation, Time.deltaTime * 120f);
}
How do I limit the rotation of my camera? I found a lot of solutions here and the forum, but most of them are mouse look oriented, and the other solutions didn’t work.