Continuous Rotation of an object Script (86243)

How i can make continuous rotation of an object from the x to the z axis ? can someone help me? ? as here in the picture http://s8.postimg.org/e875n50yt/ROTATION.jpg

Your picture doesn't help explain what you want, if anything it confuses things. Do you mean you want to smoothly rotate an object from facing the X axis direction to facing in the Z axis direction? So from a world view perspective it would start looking right, then rotate until facing forwards?

3 Answers

3

transform.Rotate(Vector3.one * 4 * Time.deltaTime);

Put that in your Update() function and it should work. You can change the “4” to any number to speed it up or slow it down. Or you can make a Speed variable and multiply it with that instead.

This... will not do what you think it does. It will rotate around all axes at once (well in sequence) at an inconsistent speed that depends on frame rate, and will keep doing this forever.

@Huacanacha Thanks, I added in the Time.deltaTime.

as well as in the images
http://s21.postimg.org/3o5ftt2kn/rotation1.jpg
http://s14.postimg.org/lmmf8o9u9/rotation2.jpg

Oh like that. All you have to do then is do transform.Rotate(Vector3.up * 4 * Time.deltaTime); And of course put it in the Update() function.

You’re describing a rotation around the y-axis.
Create a new Javascript. Insert the code below. Attach the script to the object. Adjust Spin Speed as required. Hit Play.

#pragma strict

// Rotation speed (degrees/sec)
var spinSpeed : int = 30;

function Update () {
    transform.Rotate(0, spinSpeed * Time.deltaTime, 0);
}