Hi,
I’m pretty new to Unity, and I’m trying to make an object slowly rotate continuously. I know I need to use Delta Time and I think something like Transform Vector 3? I’m not sure (I’m used to Flash and AS3, so I’m still figuring out the whole 3D coding thing). Can someone help me code these couple of lines?
Thanks a million!
I don’t have time to explain but try search on “rotate” in the scripting manual(in unity, Help, scripting manual or something)
SarperS
November 26, 2009, 10:29pm
3
Create a script and attach it to the object you want to rotate.
Here is the link to the explanation of Transform.Rotate
You could do it without using any code at all now, if you want. Just pull up the animation window and keyframe it.
Ok, I used:
function Update() {
// Slowly rotate the object arond its X axis at 1 degree/second.
transform.Rotate(Time.deltaTime, 0, 0);
// … at the same time as spinning it relative to the global
// Y axis at the same speed.
transform.Rotate(0, Time.deltaTime, 0, Space.World);
}
and now it slowly floats away (direction it floats depends on .up, .down, .left, and .right)
How do I fix this so it actually rotates?
Thanks
Fix the model so that the centre of rotation is in the centre of the object. It sounds as though it’s been exported incorrectly.
If that does not work attach the model to a default GameObject with it’s centre in the right place and rotate the parent GameObject instead.