Using DampSmooth in EulerAngle is affecting the Position.Z value of the gameObject.
I am making a top-down game and when the player turns I want my camera to turn as well but smoothly. So I wrote this code. To avoid the negative Angle problem, I created a parent object called CameraHandler and set its angle to 90 degrees. To compensate, I have set the angle of the actual camera to -90 degrees. Then I attached this code to the parent - CameraHandler. Here's the problem: When I don't use any type of SmoothDamp (SmoothDamp with vector, with float, as DampSmoothAngle), the position.z also gets affected. But when I don't use any DampSmooth, position.z doesn't get affected (of course, now there is no smoothing).
The position of the GameObject by default is (0f,0f,-11f) I have used a similar code for the player but that works fine. Player's position by default is: (x is variable, 0f,0f)
Why??? Can you please help me understand..
Here's the code
zVal = 90f;
if(camRotate){
if(player.transform.eulerAngles.z>180){
zVal = 90f + ((player.transform.localEulerAngles.z - 360f)/2f);
}else{
zVal = 90f + (player.transform.localEulerAngles.z/2f);
}
Debug.Log(zVal);
}
transform.eulerAngles = new Vector3(0f,0f,zVal);
//transform.localEulerAngles = new Vector3(0f,0f,Mathf.SmoothDampAngle(transform.localEulerAngles.z,zVal,ref velocityZero.z, 0.1f,Mathf.Infinity,Time.deltaTime));