how can i substract one axis by 180?

i have a script that rotates the character to the camera’s Y angle but my character’s face points to the camera instead of his back.
i want to do it like this :
this.transform.rotation = Quaternion.Slerp(this.transform.rotation,CameraController.rot/* minus 180*/) ,rotateSpeed * Time.deltaTime);

hope someone can help me :slight_smile:

In some ways your question is puzzling. Assuming you’ve modeled your character so that the front is looking at positive ‘Z’, rotating on the ‘Y’ by 180 with respect to the camera will have your character facing the camera. But no matter what you want, using angles may result in unanticipated rotations since there are multiple eulerAngle representing the same ‘physical’ rotation. Instead, look at using Quaternion.LookRotation(). So I’m going to assume you have a standard setup with the character running around on the XZ plane and ‘Y’ is up. And you want to match the character to only the ‘Y’ rotation of the camera. So get the forward vector of the camera and bring it down to the level of your character:

var v3 = Camara.main.transform.forward;
v3.y = transform.forward;
Quaternion q = Quaternion.LookRotation(v3);
Quaternion.Slerp(transform.rotation,q,rotateSpeed * Time.deltaTime); 

And if you really do want it 180 degrees from the camera rotaiton, use ‘back’ (-forward) for your vector.

var v3 = -Camara.main.transform.forward;
v3.y = transform.forward;
Quaternion q = Quaternion.LookRotation(v3);
Quaternion.Slerp(transform.rotation,q,rotateSpeed * Time.deltaTime); 

I think it’s as simple as either dividing by 2 or multiplying by 0.5…maybe