# Really simple rotation question

Hello everyone, I’m still trying to figure out rotations. Here is what i want: There are 2 gameobjects. One gameobject’s rotation will be the same the other’s rotation. But only rotation.y. How can i do that?

``````transform.rotation = Quaternion.Euler(0f, transformToCopy.rotation.eulerAngles.y, 0f);
``````
1 Like

Thank you! I have searched Quaternion.EulerAngles. I saw it is deprecated. And i didn’t look eulerangles again. But it seems transform.rotation.eulerAngles still works. Thanks again.

Part of the reason to avoid eulerAngles is the (0,eulerAngles.y,0) method doesn’t always work. Whenever your object is upside-down it can point in the opposite direction. I’ve got a long explanation in my angles and rotations notes in section 4 of http://www.taxesforcatses.com/vectorW/ch4Rotation.pdf

Most people keep the object with z-rotation 0, so (0,eulerAngles.y.0) is fine, but a general way might be (these are always puzzles to figure out, so there could be a simpler one):

// standard flat-facing of other object:
Vector3 d1=otherTransform.forward; d1.y=0;
// now look that way:
if(d1!=Vector3.zero) // not straight up, which is random y-rotation
transform.rotation=Quaternion.LookRotation(d1);