The problem is that the camera has a wider rotation than the rigidbody, I tried to make the offset wider but to no avail. Here’s the code I used.
public class NewCamScript : MonoBehaviour {
public Rigidbody target;
public float yawInput = 0.0f;
public float yawSpeed = 50.0f;
public float currentRot = 10.0f;
public float rotMin = 5.0f;
public float rotMax = 15.0f;
// Update is called once per frame
void Update () {
if(Input.GetKey(KeyCode.RightArrow))if(Input.GetKey(KeyCode.LeftArrow))
yawInput -= Input.GetAxis ("Horizontal") * yawSpeed * Time.deltaTime;//pressing left/right arrows or "a" and "d" will rotate the camera
yawInput = Mathf.Clamp(currentRot,rotMin,rotMax);
}
// Updates every frame a little later
private void LateUpdate()
{
transform.RotateAround (target.position, Vector3.up, yawInput);//rotates the camera around the player (rigidbody = target)
}
}