Object Spin Unity Script

Object Spin Unity Script

Sep 11, 2023

If you want to make an object spin in Unity, just attach this simple script to it:

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class MakeItemSpin : MonoBehaviour

{

[SerializeField] Vector3 rotateSpeed;

private void Update()

{

transform.Rotate(rotateSpeed.x * Time.deltaTime, rotateSpeed.y * Time.deltaTime , rotateSpeed.z * Time.deltaTime);

}

}

Set a spin speed in the Inspector. Set the rotate speeds for each axis in the rotateSpeed Inspector slot.

Enjoy this post?

Buy DJ a coffee

More from DJ