I’m working on a camera script and i want to make that when i’m moving to the left, camera turns to 90 degree left and when i’m moving right, camera turns 90 degree right(from the back of the character). I’m not copying the full script:
var horizontal = Input.GetAxis("Horizontal");
else if(horizontal == 1 || horizontal == -1){
Debug.Log(Input.GetAxis("Horizontal"));
wantedRotationAngle = 90;
wantedRotationAngle *= horizontal;
currentRotationAngle = Mathf.Lerp(currentRotationAngle, wantedRotationAngle, Time.deltaTime * rotationDamping);
currentHeight = Mathf.Lerp(currentHeight, wantedHeight, Time.deltaTime * heightDamping);
var currentHRotation = Quaternion.Euler(0, currentRotationAngle, 0);
transform.position = target.position;
transform.position -= currentHRotation * Vector3.forward * distance;
transform.position.y = currentHeight;
And the problem is: When i’m moving to the left(horizontal = -1) it tries to turn 270 degrees. And no problem with right. How can i make it turn 90 degrees opposite direction?