• unity3d角(jiǎo)度(dù)偏移(yí)計算方法

    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);//新的(de)方向相對舊的方向的偏轉角度
        }
    }
    
    AV永久天堂网_奇米狠狠色_亚洲欧美日韩动漫_欧美日韩视频在线观看免费一区二区_日韩精品一二三区_国产AV网站18禁止人_久久久久久精品人妻免费网站不卡_国产最新视频_另类免费视频在线视频二区_久久精品免视国产