Skip to content

Instantly share code, notes, and snippets.

@reunono
Created March 27, 2018 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reunono/ff2c6460df1ee031947d8f198e3b6670 to your computer and use it in GitHub Desktop.
Save reunono/ff2c6460df1ee031947d8f198e3b6670 to your computer and use it in GitHub Desktop.
AutoRotate
using UnityEngine;
using System.Collections;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this class to a GameObject to make it rotate on itself
/// </summary>
public class AutoRotate : MonoBehaviour
{
public Space RotationSpace = Space.Self;
/// The rotation speed. Positive means clockwise, negative means counter clockwise.
public Vector3 RotationSpeed = new Vector3(100f,0f,0f);
/// <summary>
/// Makes the object rotate on its center every frame.
/// </summary>
protected virtual void Update ()
{
transform.Rotate(RotationSpeed*Time.deltaTime,RotationSpace);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment