AlwaysFaceCamera rotation bug
Posted: Sat Oct 17, 2020 7:37 pm
In this code in AlwaysFaceCamera.cs, for the code concerning yAxisOnly, you accidentally apply the current x-rotation to both the x and the z of the resulting rotation.
Code: Select all
private void Update()
{
if (m_mainCamera == null) m_mainCamera = Camera.main;
if (m_mainCamera == null) return;
if (rotate180)
{
if (yAxisOnly)
{
transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, (m_mainCamera.transform.rotation.eulerAngles + 180f * Vector3.up).y, transform.rotation.eulerAngles.x);
}
else
{
transform.rotation = Quaternion.LookRotation(-m_mainCamera.transform.forward, m_mainCamera.transform.up);
}
}
else
{
if (yAxisOnly)
{
transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, m_mainCamera.transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.x);
}
else
{
transform.rotation = m_mainCamera.transform.rotation;
}
}
}