TransformRotator Rotate Game Objects inside Unity Engine

S: TransformRotator, Setup any GameObject to Rotate

The TransformRotator can Rotate any Object within Unity around any Axis.

Once the Transform Rotator Script is attached to a GameObject it will start Rotating on Update in every Frame.

TransformRotator.cs

				
					using UnityEngine;

/// <summary>
/// We use Time.deltaTime so the Rotator can be fine adjusted
/// Ranges from 5 - 50 work well
/// </summary>
public class TransformRotator : MonoBehaviour
{
    [SerializeField] float xAngle = 0;
    [SerializeField] float yAngle = 0;
    [SerializeField] float zAngle = 0;

    void Update()
    {
        transform.Rotate(xAngle * Time.deltaTime, yAngle * Time.deltaTime, zAngle * Time.deltaTime);
    }
}

				
			

To make the TransformRotator more adjustable we make use of Time.deltaTime so we can use Angle Numbers in higher Values. Best Ranges are usually around 5 – 50, depending on your Project it can be more or less.

Happy Development <3

Leave a Reply

Your email address will not be published.