免费国产网站_秋霞午夜一区二区三区视频_99热在线看_日韩精品久久一区二区_午夜看一级毛片_天天鲁在视频在线观看

  • 您的位置:首頁 > 新聞動態(tài) > 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);//新的方向相對舊的方向的偏轉(zhuǎn)角度
        }
    }
    
    主站蜘蛛池模板: 潍坊市| 宣威市| 张家口市| 北碚区| 衡南县| 道真| 崇文区| 密山市| 勃利县| 上高县| 望江县| 湄潭县| 黔南| 宁都县| 务川| 芜湖市| 马山县| 时尚| 石家庄市| 沧州市| 台东县| 嫩江县| 古田县| 民丰县| 东乌珠穆沁旗| 保康县| 偃师市| 黑水县| 铁岭县| 平罗县| 泗水县| 曲靖市| 土默特右旗| 莱西市| 钦州市| 周口市| 莱西市| 安新县| 文昌市| 邵阳县| 丹凤县|