- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
Alp-Giray-Savrum · Feb 01, 2014 at 02:19 PM ·
transformrotateupdatetransform.rotation
Rotate Method via Update ?
Hello again, I don't want to use animations so can i make a rotation anim via JS ?
function Update() {
gameObject.transform.rotation.x += 10 * Time.deltaTime;
}
it's like an asteroid but this code isn't working :S what can i do ?
Comment
Answer by Scribe · Feb 01, 2014 at 02:33 PM
Hi!
As transform.rotation is a quaternion not an euler angle (its made of 4 components not 3 and they change between -1 and 1 I believe) it is quite difficult to use transform.rotation to set anything yourself, unless you are simply setting one object to have the same rotation as another object.
For you a better method would be to use:
transform.Rotate(Vector3(10, 0, 0) * Time.deltaTime);
By default this will change the roation relative to the objects axis, if you want it relative to world space just change it to:
transform.Rotate(Vector3(10, 0, 0) * Time.deltaTime, Space.World);
Hope that helps! Scribe