From 7f493f682503f5186308de7b8f74b5b49233cfe4 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Thu, 2 Nov 2023 11:51:31 +0800 Subject: +init --- GameCode/SimpleRotator.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 GameCode/SimpleRotator.cs (limited to 'GameCode/SimpleRotator.cs') diff --git a/GameCode/SimpleRotator.cs b/GameCode/SimpleRotator.cs new file mode 100644 index 0000000..aa2d0b4 --- /dev/null +++ b/GameCode/SimpleRotator.cs @@ -0,0 +1,23 @@ +using UnityEngine; + +public class SimpleRotator : MonoBehaviour +{ + public Vector3 rotationDelta; + + public Space relativeTo; + + public bool randomYRotationOnEnable; + + private void OnEnable() + { + if (randomYRotationOnEnable) + { + base.transform.Rotate(Vector3.up * Random.value * 360f, Space.World); + } + } + + private void Update() + { + base.transform.Rotate(rotationDelta * Time.deltaTime, relativeTo); + } +} -- cgit v1.1-26-g67d0