Skip to content

Instantly share code, notes, and snippets.

@greggraham
Created June 21, 2011 00:54
Show Gist options
  • Save greggraham/1036987 to your computer and use it in GitHub Desktop.
Save greggraham/1036987 to your computer and use it in GitHub Desktop.
Unity script for simple object rotation
// simple rotation around the Y-axis
var speed = 5.0;
function Update () {
transform.Rotate(0, speed*Time.deltaTime, 0);
}
@jestinjj
Copy link

jestinjj commented Jul 4, 2019

Nice script

@MiloCookie
Copy link

hey dude how can i use it

@greggraham
Copy link
Author

@QeustionHub, I don't know that I really remember. I posted this 9 years ago I'm sure to answer someone's question, but I've hardly used Unity since then. The main point is to use Time.deltaTime to get a continuously increasing value for rotation, but you probably need to multiply it by a value (the variable "speed") to scale it to the speed you want. The variable "transform" would be associated with some object in your Unity world. I expect the three parameters for Rotate are the X, Y, and Z axis rotation amounts. In this example, you are only changing the Y rotation, keeping X and Z at 0.

@MiloCookie
Copy link

Thanks dude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment