public class CameraRotation : MonoBehaviour {
public Transform camera;
public Vector3 vector;
public float rotateValue;
public float smoothSpeed = 0.125f;
void LateUpdate()
{
vector = new Vector3(0f, 0f, rotateValue);
Vector3 smoothRotation = Vector3.Lerp(transform.eulerAngles, end,smoothSpeed *
Time.deltaTime);
if (Input.GetKey("a"))
{
transform.eulerAngles = -smoothRotation;
}
else if(Input.GetKey("d"))
{
transform.eulerAngles = smoothRotation;
}
else
{
transform.eulerAngles = Vector3.zero;
}
}
}
I tried to Lerp the camera angle on the z axis. But it works only in positive direction. If the value gets negative it turns to a weird spot.