Help ! rotation issue !

Hi guys sorry for the trouble once again. The method that i tried yesterday wasn’t working.

Ok the problem is this. Imagine with me. I want a plane in front of the cube to inherit only the x and z axis rotation of the cube. However after a week of trying, i am getting no where.

I tried using transform.rotation.x but it returns me strange value, etc
-3.090862E_08.

I tried transform.eulerAngles.x but to no avail as well. as the rotation in unity fully utilize 3 axis, I am unable to only take the information of the 2 axis and pass it to the plane.

Tried parenting the plane to the cube and then manually using transform.Rotate to rotate the y axis of the plane back to its original position but again, to no avail.

Do help me pls. I am kind of at a desperate end now. Am just a student but the dead line is over due and i am still stuck at this kind of stupid issue.

Any idea of cheating or solutions to my questions are welcomed.
Thank you very much guys.

This should be the right function to call. It’s not quite clear from your post what error you encountered with this.

Untested, but I’d bet this should work:

Vector3 cubeAngle = cube.transform.eulerAngles;
cubeAngle.y = 0;
plane.transform.eulerAngles = cubeAngle;

For JS, replace ‘Vector3’ with ‘var’. ‘cube’ and ‘plane’ are references to the cube and plane GameObjects respectively.

i know this is the way but this effect is not what i wanted. Like i said i wanted the x and z axis from the parent but not the y axis. :frowning:

help anyone?

oh i misread your reply. yeah tried that but it is not working :frowning:

C#

Vector3 cubeAngle = cube.transform.eulerAngles;

plane.transform.eulerAngles = new Vector3( cube.transform.eulerAngles.x,
plane.transform.eulerAngle.y,
 cube.transform.eulerAngles.z );