FrisbeeRotateController.cs 686 B

123456789101112131415161718192021222324
  1. using Unity.Mathematics;
  2. using UnityEngine;
  3. /* 用来控制飞盘自动旋转的功能
  4. * 这个脚本可以附加到飞盘对象上,使其在游戏中自动旋转
  5. */
  6. public class FrisbeeRotateController : MonoBehaviour
  7. {
  8. public float rotationSpeed = 0f; // 旋转速度,单位为度/秒
  9. // Start is called once before the first execution of Update after the MonoBehaviour is created
  10. void Start()
  11. {
  12. }
  13. // Update is called once per frame
  14. void Update()
  15. {
  16. // 计算每帧旋转的角度
  17. float rotationAmount = rotationSpeed * Time.deltaTime;
  18. // 应用旋转
  19. transform.Rotate(0, 0, rotationAmount, Space.Self);
  20. }
  21. }