using UnityEngine; namespace GrassCutter { /// Endless spin about a local axis for windmill sails, weather vanes and other set dressing, with an optional 3D loop sound. public class Spin : MonoBehaviour { public Vector3 axis = Vector3.up; public float degreesPerSecond = 60f; public string loopClip; public float loopVolume = 0.25f; void Start() { // desync identical pieces transform.Rotate(axis, Random.Range(0f, 360f), Space.Self); if (!string.IsNullOrEmpty(loopClip) && !Application.isBatchMode) Sfx.Loop(loopClip, transform, loopVolume); } void Update() => transform.Rotate(axis, degreesPerSecond * Time.deltaTime, Space.Self); } }