'Camera rotation system isn't orientating itself properly
public GameObject player;
public Rigidbody rb;
private Vector3 offset;
public Vector3 minCamAngle;
public Vector3 maxCamAngle;
void Start()
{
rb = player.GetComponent<Rigidbody>();
offset = transform.position - player.transform.position;
}
// Update is called once per frame
void LateUpdate()
{
Quaternion desiredRotation = Quaternion.LookRotation(new Vector3(Mathf.Clamp(rb.velocity.x, minCamAngle.x, maxCamAngle.x), Mathf.Clamp(rb.velocity.y, minCamAngle.y, maxCamAngle.y), Mathf.Clamp(rb.velocity.z, minCamAngle.z, maxCamAngle.z)));
transform.rotation = Quaternion.Slerp(transform.rotation, desiredRotation, Time.deltaTime);
transform.position = player.transform.position + offset;
}
This is the code i'm using to rotate the camera based on the players velocity except when i set the minimum and maximum x rotation angle to 34 the camera always sets its rotation to an X rotation of -65.61 at the start of the game. I'm not sure what is happening and some help would be appreciated, Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
