CompassPors.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class CompassPors : MonoBehaviour
  5. {
  6. public int thiAngle = 0;
  7. public int rotateSpeed = 2;
  8. public bool openRotate = true;
  9. void Update()
  10. {
  11. //if (Input.GetKeyDown(KeyCode.T))
  12. //{
  13. // openRotate = true;
  14. // StartCoroutine(stop());
  15. //}
  16. if (openRotate)
  17. {
  18. }
  19. PointerRotate();
  20. }
  21. /// <summary>
  22. /// 控制指针旋转
  23. /// </summary>
  24. private void PointerRotate()
  25. {
  26. //if (thiAngle > -0.001f && thiAngle <= 180)
  27. //{
  28. // Quaternion target = Quaternion.Euler(0, 0, (90 - thiAngle));
  29. // transform.rotation = Quaternion.RotateTowards(transform.rotation, target, rotateSpeed);
  30. //}
  31. Quaternion target = Quaternion.Euler((90 - thiAngle),0, 0);
  32. transform.rotation = Quaternion.RotateTowards(transform.rotation, target, rotateSpeed);
  33. }
  34. /// <summary>
  35. /// 停止检测
  36. /// </summary>
  37. /// <returns></returns>
  38. private IEnumerator stop()
  39. {
  40. yield return new WaitForSeconds(2);
  41. openRotate = false;
  42. Debug.Log("tingzhi");
  43. }
  44. }