- Home /
Rotation like in editor
I've been messing with rotation the last few weeks and I haven't really figured it out yet.
In the editor I just have to edit the X axis rotation to get the effect I want. Is there anyway to rotate your object in script the way you do it in the editor, only over the X axis?
Answer by DeveshPandey · Nov 28, 2012 at 09:40 AM
Write these lines in Update() function and put this script on the object that you want to rotate.
var speed:float = 50;// as needed
transform.Rotate(Time.deltaTime * speed,0 , 0);
But he can manage the Rotation speed as well threw adding a variable in multiplication with time.deltatime....
@fafase : exactly, we can manage speed by as $$anonymous$$aulik2208 says.
var speed:float = 50;// as needed
transform.Rotate(Time.deltaTime * speed,0 , 0);
yep obviously, I just meant so because you only have deltaTime there.
Answer by Maulik2208 · Nov 28, 2012 at 09:59 AM
Means You want the same effect after pressing "E" in editor in unity.....a circle appears and by that Rotate the Object??? or Just Rotate in case of just Rotate Go with the Answer By @DeveshPandey and if you want to define the Rotation speed then just write
`transform.Rotate(RotationSpeed * Time.deltaTime,0 , 0);` //define rotation speed as per your need
I mean in the Inspector, in the transform. If I edit my X rotation there it goes the way I want it to. I'm now using LookRotation quaternions aimed at an object on mouseposition in 2D space, which works fine.
But as I'm trying to Lerp it, it Lerps over all axi ins$$anonymous$$d of only the X.
You could have a look at this for how to use quaternions http://unitygems.com/quaternions-rotations-part-1-c/
Your answer
Follow this Question
Related Questions
Rotating tank barrel on X axis while the parent Turret rotates on Y axis 2 Answers
How do I rotate a game object in 45 degree steps per keystroke? 2 Answers
90 Degree stopping rotation on y-axis issue 0 Answers
Rotation math question: car movement on a cylinder 0 Answers
Rotate on one axis and check if angle is inside desired range 2 Answers