using UnityEngine; public class GearController : MonoBehaviour { [Header("齿轮参数")] public float rotationSpeed = 360f; public float snapDistance = 0.3f; public float detachDistance = 10.0f; private bool isRotating = false; public void SetRotation(bool shouldRotate) { isRotating = shouldRotate; } private void Update() { if (isRotating) { transform.Rotate(Vector3.forward, -rotationSpeed * Time.deltaTime); } } }