- Home /
rotate 90% in local space
ok so i have a cube and it responds to the directional keys. whichever key is pressed it needs to add 90 degrees to its rotation in that direction.
(i can do it just fine with Transform.rotate except if the cube is facing down and i rotate to the left instead it rotates the object along what is now the objects z axis)
how do i rotate the object in increments of 90 degrees relative to the objects up down left right ( v.s global directions)?
Answer by creative72 · Aug 05, 2011 at 04:04 AM
answer : Transform.TransformDirection converts local to world space keeping relative left right up down
Answer by creative72 · Aug 05, 2011 at 01:16 AM
i meant degrees not quite sure why i put %
BerggreenD$$anonymous$$ added a comment to your question, why do you reply with an answer? Answers have only one usage: answer the question.
im unfamiliar with Unity's answers and wasn't aware there was a comment box. does it really matter that i call a comment an answer anyway when you have the same exact result which is passing an explanation. in fact that comment was an answer to your question
Answer by kiki.du · Aug 05, 2011 at 01:18 AM
it is not way to rotate the object in the same place. but u can mark down the number on the inspector window. i mean the x,y,z number. then change to play with the number would be one of the easy way to do that.
Answer by Bunny83 · Aug 05, 2011 at 01:26 AM
Transform.Rotate has another parameter that specifies the Space in which it should rotate the object. The default is Space.Self which is already local space. Maybe you want to rotate it in world space?
yes that would work except for i need an instantaneous exact rotation of 90 degrees where one frame the object is 0 and the next its 90. not over time