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 ?

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

yes you can, but you have to use Rotate Method to do that.
If you want to assign a particular angle you have to use for example:

transform.rotation = Quaternion.Euler(30, 0, -90);

or:

transform.eulerAngles = new Vector3(30, 0, -90);