Last active
July 30, 2021 14:51
-
-
Save kurtdekker/cc6b8c69bc89174bb4b94581920e9cae to your computer and use it in GitHub Desktop.
Spin an object on the Y axis in Unity3D.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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