# How to Set a Single Axis Rotation of a GameObject?

 0 What is the most efficient way of setting a rotation of a single axis of a GameObject without changing the other values? more ▼ asked Dec 14 '09 at 05:08 AM Devin Reimer 58 ● 3 ● 3 ● 6 Jun 04 '12 at 08:25 PM Cawas add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 what jaap did can be done by transform.rotate and i think it's not what you want and you want to set the value directly. you can use his code but remove the "rot*" and then the code will be ``````transform.rotation = Quaternion.Euler(0, 90, 0); `````` if you want to add some value to any of the x,y,z values simply use ``````transform.Rotate (0,0,10); `````` this will add 10 to Z value more ▼ answered Dec 28 '09 at 06:08 PM Ashkan_gc 9.1k ● 33 ● 56 ● 117 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 I think this is what you're looking for : ``````// Sets the transforms rotation to rotate 30 degrees around the y-axis transform.rotation = Quaternion.AngleAxis(30, Vector3.up);`````` more ▼ answered Dec 14 '09 at 03:49 PM PatHightree 379 ● 7 ● 10 ● 20 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 Don't know what you exactly want but maybe this is it: ``````var rot = transform.rotation; transform.rotation = rot * Quaternion.Euler(0, 90, 0); // this is 90 degrees around y axis `````` more ▼ answered Dec 14 '09 at 06:09 AM Jaap Kreijkamp 6.4k ● 20 ● 26 ● 70 this can be done easily by transform.rotate Dec 28 '09 at 06:00 PM Ashkan_gc add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 The rotations are stored as quaternions, so you can store the appropriate quaternion and set transform.rotation to that. Perhaps an explanation of what you are trying to accomplish would help. If you go into "Debug mode" and watch the rotation values change, you can see how just changing one axis's value isn't really more efficient. It only looks that way in "Normal mode". more ▼ answered Dec 14 '09 at 05:45 AM Jessy 15.6k ● 72 ● 95 ● 196 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email: