Rotation.cs 518 B

123456789101112131415161718
  1. using UnityEngine;
  2. public class ContinuousRotation : MonoBehaviour
  3. {
  4. // 控制旋转的速度(每秒旋转的角度)
  5. public float rotationSpeedX = 0f; // X轴旋转速度
  6. public float rotationSpeedY = 0f; // Y轴旋转速度
  7. public float rotationSpeedZ = 0f; // Z轴旋转速度
  8. void Update()
  9. {
  10. // 按照设定的速度围绕指定轴旋转
  11. transform.Rotate(rotationSpeedX * Time.deltaTime,
  12. rotationSpeedY * Time.deltaTime,
  13. rotationSpeedZ * Time.deltaTime);
  14. }
  15. }