So I am working on a camera controller that’s pretty similar to the ones found in newer 3d Zelda games following this tutorial series: Unity Third Person Control Tutorials - YouTube
But it’s pretty old, I’m currently on tutorial #12, and that’s when i hit my problem. When I try to move my player forward/backward the camera looks at the player at an angle (30 degrees give or take) and quite frankly, I have no idea how to fix it. Here’s the code snippet:
[SerializeField]
private float distAway;
[SerializeField]
private float distUp;
[SerializeField]
private Transform followXFrom;
[SerializeField]
private float lookDirectDampTime = 0.1f;
private Vector3 velocityLookDirect = Vector3.zero;
private Vector3 curLookDirect;
private Vector3 targPos;
private Vector3 lookDirect;
followXFrom = GameObject.FindWithTag("Player").transform;
lookDirect = followXFrom.forward;
curLookDirect = followXFrom.forward;
case CamStates.Behind:
ResetCamera();
if (playerLogic.Speed > playerLogic.LocomotionThreshold && playerLogic.IsInLocomotion())
{
lookDirect = Vector3.Lerp(followXFrom.right * (leftX < 0 ? 1f : -1f), followXFrom.forward * (leftY < 0 ? -1f : 1f), Mathf.Abs(Vector3.Dot(this.transform.forward, followXFrom.forward)));
curLookDirect = Vector3.Normalize(characterOffset - this.transform.position);
curLookDirect.y = 0;
curLookDirect = Vector3.SmoothDamp(curLookDirect, lookDirect, ref velocityLookDirect, lookDirectDampTime);
}
break;
private void ResetCamera()
{
transform.localRotation = Quaternion.Lerp(transform.localRotation, Quaternion.identity, Time.deltaTime);
}
As usual, Any help is greatly appreciated