老公原谅我在老公面前,小情侣在废弃楼房里约会电视剧,大赛每日一赛吃瓜爆料

  • 您的位置:首页 > 新闻动态 > Unity3D

    unity3d角度偏移计算方法

    2019/4/9??????点击:
    using UnityEngine;
    using System.Collections;
     
    public class UserAnimatorMove : MonoBehaviour
    {
        private Vector3 oldVector3;
        private Vector3 newVector3;
        private Quaternion oldQuaternion;
        private Vector3 newRotatinForward;
        void Start()
        {
    
        }
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.F1))
            {
     
                oldVector3 = this.transform.position;
                oldQuaternion = this.transform.rotation;
            }
            if (Input.GetKeyDown(KeyCode.F2))
            {
                StartCoroutine(MovePoint());
            }
        }
        private IEnumerator MovePoint()
        {
            //    oldVector3 = this.transform.position;
            //   oldQuaternion = this.transform.rotation;
            yield return new WaitForSeconds(0.2f);
            newVector3 = this.transform.position;
            newRotatinForward = this.transform.forward;
     
            float lenth = Vector3.Distance(oldVector3, newVector3);
            Vector3 velocity = Quaternion.Inverse(oldQuaternion) * newRotatinForward;
            float angle = Mathf.Atan2(velocity.x, velocity.z) * 180.0f / 3.14159f;
            Debug.Log(angle);//新的方向相对旧的方向的偏转角度
        }
    }
    
    主站蜘蛛池模板: 德昌县| 嘉义县| 阿瓦提县| 当涂县| 牙克石市| 黑山县| 会同县| 墨竹工卡县| 新余市| 大关县| 武川县| 万安县| 呼和浩特市| 彩票| 清水县| 长垣县| 浠水县| 招远市| 江山市| 泽普县| 咸宁市| 阳朔县| 冀州市| 邮箱| 泾阳县| 西藏| 荃湾区| 上饶县| 盐亭县| 崇左市| 衢州市| 昌乐县| 彭阳县| 临海市| 锦州市| 甘泉县| 方城县| 涪陵区| 治多县| 英超| 淳化县|