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

  • 您的位置:首页 > 新闻动态 > 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);//新的方向相对旧的方向的偏转角度
        }
    }
    
    主站蜘蛛池模板: 弋阳县| 玛纳斯县| 运城市| 阳春市| 深水埗区| 高要市| 黄骅市| 县级市| 息烽县| 张家川| 河南省| 宜丰县| 青浦区| 友谊县| 秭归县| 宁乡县| 黄浦区| 江西省| 南平市| 新乐市| 息烽县| 尚义县| 滕州市| 大埔区| 砚山县| 汶上县| 三亚市| 乐安县| 太仆寺旗| 通榆县| 凤山市| 湖北省| 汾阳市| 临高县| 专栏| 图们市| 诸城市| 商河县| 农安县| 庆元县| 卢氏县|