How would I make an object constantly rotate in a single direction? This particular time being in the Z axis? For all eternity? Undisturbed forever?
void Update ()
{
transform.Rotate (0,0,50*Time.deltaTime); //rotates 50 degrees per second around z axis
}
take a look at link texttransform class and it's methods
var degreesPerSecond : float = 50.0;
function Update() { transform.Rotate(Vector3.up * degreesPerSecond * Time.deltaTime, Space.Self); transform.Rotate(Vector3.left* degreesPerSecond * Time.deltaTime,Space.Self);
rigidbody.isKinematic = true;
}
you can use this one also to rotate constant speed as u want.
There is a script ready in case of Lerpz which can be downloaded directly from the official site. Is the tutorial 3dplatform
I cant make it work
I just want a COG rotiation in the background. Do I have to turn this asset into a Prefab or can I just drop it on the scene and add some sort of script to make it rotate? (2D plaformer)
you can use this:
void Start () {
z = 0.5f; //velocity
}
void Update () {
game.transform.Rotate(new Vector3(0,0,z)); //applying rotation
}
the transform.Rotate
function is applied to the existing rotation,not to the 0 of that axis.
If the object is rotated 25 degrees and you apply to the rotation 2 degrees , the result will be tilted 25+2=27 degrees
Here is a script that will spin an object round and round
void Update() { float z = Mathf.PingPong(t:Time.time, length:1f); Vector3 axis = new Vector3(x:1, y:1, z); transform.Rotate(axis, angle:1f); }