title: Unity set player Y-rotation equal to that of the camera Y-rotaion
body: <p>I need to set directly the Y-Rotation of the player to be equal to the <code>Camera.main</code> Y-Rotation I have searched a lot but can't find the answer.</p>
  
  <p>I know it is simple but I can't manage it.</p>
  
  <p><strong>Edit:</strong> I tried this code</p>
  
  <p><code>transform.rotation = Quaternion.Euler(Camera.main.transform.eulerAngles);</code></p>
  
  <p>But it set the rotation of the whole rotation of the object equal to the rotation of the camera X,Y,and Z but what I want is to set only the y rotation.Thanks for help.</p>
  
  <p><strong>Edit2:</strong><a href="https://i.stack.imgur.com/W3M4z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W3M4z.png" alt="PlayerImage"></a></p>
  
  <blockquote>
    <p>I forgot to say whay I am using this in I am making a VR Game so when the player rotates his head the camera rotates successfully.</p>
    
    <p><strong>Note:</strong> Why I want to do that? because when my player has to move forward it has to have the same y rotation of the camera.</p>
  </blockquote>