Skip to content

Instantly share code, notes, and snippets.

@kurtdekker
Last active July 30, 2021 14:51
Show Gist options
  • Save kurtdekker/cc6b8c69bc89174bb4b94581920e9cae to your computer and use it in GitHub Desktop.
Save kurtdekker/cc6b8c69bc89174bb4b94581920e9cae to your computer and use it in GitHub Desktop.
Spin an object on the Y axis in Unity3D.
using UnityEngine;
// @kurtdekker
// Place on a GameObject, set the desired rate of spin
public class SpinOnY : MonoBehaviour
{
[Header( "Degrees per second.")]
public float RateOfRotation = 200.0f;
float age;
void Update ()
{
age += Time.deltaTime;
transform.localRotation = Quaternion.Euler( 0, age * RateOfRotation, 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment