Files
grass-cutters/Assets/Scripts/World/Spin.cs
NiemandKG d1c3761e58 Grass Cutters Together: the project as of moon-sweepers f3666f0
A clean start for the shared repository: the Unity project (Assets, Packages, ProjectSettings), ArtSource, Docs and
Tools as they stood at f3666f0 in the old local repository, with its generated prefabs and scene brought up to date.
Images, audio, models and binaries go through Git LFS (.gitattributes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 18:44:40 +06:00

23 lines
775 B
C#

using UnityEngine;
namespace GrassCutter
{
/// <summary>Endless spin about a local axis for windmill sails, weather vanes and other set dressing, with an optional 3D loop sound.</summary>
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);
}
}