AlwaysFaceCamera rotation bug

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Ultroman
Posts: 39
Joined: Thu Sep 17, 2020 7:47 am

AlwaysFaceCamera rotation bug

Post by Ultroman »

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;
		}
	}
}
User avatar
Tony Li
Posts: 21954
Joined: Thu Jul 18, 2013 1:27 pm

Re: AlwaysFaceCamera rotation bug

Post by Tony Li »

Oops, thanks for reporting that. I'll make sure it's fixed in the next release.
Post Reply