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

  • 您的位置:首页 > 新闻动态 > 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);//新的方向相对旧的方向的偏转角度
        }
    }
    
    主站蜘蛛池模板: 岳阳县| 雅江县| 荥经县| 定州市| 晋江市| 屏南县| 沛县| 横山县| 东至县| 太白县| 东辽县| 乡城县| 招远市| 丽江市| 临朐县| 乌兰县| 红原县| 长泰县| 峡江县| 方城县| 翼城县| 东丽区| 萨迦县| 蓝田县| 嘉祥县| 孝义市| 忻州市| 拉萨市| 西吉县| 女性| 灌云县| 松阳县| 巧家县| 德安县| 泉州市| 镇康县| 东阿县| 延庆县| 新丰县| 陆河县| 潼关县|