Files
TaiWan/Assets/Roaming/Scripts/Widget/RotateObject.cs

36 lines
742 B
C#
Raw Normal View History

2025-10-31 15:20:38 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateObject : MonoBehaviour
{
public float rotateSpeed = 5f;
public bool rotateAlways = true;
public Vector3 rotateDir = Vector3.up;
bool enableRotate;
// Start is called before the first frame update
void OnTriggerEnter(Collider other)
{
enableRotate = true;
}
// Start is called before the first frame update
void OnTriggerExit(Collider other)
{
enableRotate = false;
}
// Update is called once per frame
void Update()
{
if ( rotateAlways || enableRotate)
{
transform.Rotate(rotateDir * Time.deltaTime * rotateSpeed);
}
}
}