123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CompassPors : MonoBehaviour
- {
- public int thiAngle = 0;
- public int rotateSpeed = 2;
- public bool openRotate = true;
- void Update()
- {
- //if (Input.GetKeyDown(KeyCode.T))
- //{
- // openRotate = true;
- // StartCoroutine(stop());
- //}
- if (openRotate)
- {
-
- }
- PointerRotate();
- }
- /// <summary>
- /// 控制指针旋转
- /// </summary>
- private void PointerRotate()
- {
- //if (thiAngle > -0.001f && thiAngle <= 180)
- //{
- // Quaternion target = Quaternion.Euler(0, 0, (90 - thiAngle));
- // transform.rotation = Quaternion.RotateTowards(transform.rotation, target, rotateSpeed);
- //}
- Quaternion target = Quaternion.Euler((90 - thiAngle),0, 0);
- transform.rotation = Quaternion.RotateTowards(transform.rotation, target, rotateSpeed);
- }
- /// <summary>
- /// 停止检测
- /// </summary>
- /// <returns></returns>
- private IEnumerator stop()
- {
- yield return new WaitForSeconds(2);
- openRotate = false;
- Debug.Log("tingzhi");
- }
- }
|