Different offset between object and camera

Helo guys, I Have a problem with the rotation between the player and the Main camera, the problem is that I use the input manager for move the direction of camera, I copy it and paste on the player the same rotation through the following code

 transform.localRotation = Quaternion.AngleAxis(this.cameraTransform.rotation.y * 180f, Vector3.up);

but almost have a offset between them

the red line represents the forward of player and the blue the camera, so almost always exist a different between the camera and the player except when the camera look has a rotation of 0 or 180, what am I doing wrong?

rotation is a quaternion. Thus, I don’t think rotation.y is what you want to be using here.
Try using EulerAngles if you’re not versed in Quaternions:

1 Like

Yes, what SF_Frank suggests above… that rotation.y is not what you think it is. :slight_smile:

ALSO… just so you know, Camera stuff is pretty tricky… you may wish to consider using Cinemachine from the Unity Package Manager.

There’s even a dedicated forum: Unity Engine - Unity Discussions

thanks you guys, yeah the solution was use eulerAngles :slight_smile: