Last active
April 12, 2021 04:15
-
-
Save rsaenzi/0488df422e5517b32bdecc7871aef7d3 to your computer and use it in GitHub Desktop.
Script for Unity to rotate a GameObject around Y axis with constant rotation speed
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
| // | |
| // SelfRotation.cs | |
| // | |
| // Created by Rigoberto Sáenz Imbacuán (https://linkedin.com/in/rsaenzi/) | |
| // Copyright © 2021. All rights reserved. | |
| // | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| public class SelfRotation : MonoBehaviour { | |
| [Tooltip("Rotation speed around its Y axis in degrees/seconds")] | |
| public float rotationSpeed; | |
| void Update() { | |
| // Rotates the game object ´rotationSpeed´ degrees per second | |
| this.transform.Rotate(Vector3.up * rotationSpeed * Time.deltaTime, Space.Self); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment