Unity - A计划(永久有效期) 扫二维码继续学习 二维码时效为半小时

(196评价)
价格: 4019.00元
键盘左右方向键转向速度不一致,是怎么回事?
新手123发起了问答2017-07-21
2
回复
439
浏览
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        if (Mathf.Abs(h) > 0.1 || v > 0.1)
        {
            anim.SetFloat("Speed", Mathf.Lerp(anim.GetFloat("Speed"), 5.6f, AC * Time.deltaTime));
            Vector3 TDir = new Vector3(h, 0, v);//目标方向
            Vector3 NDir = this.gameObject.transform.position;
            float angle = Vector3.Angle(NDir, TDir);//取得夹角
            Debug.Log(h);
            if (h<0)
            {
               angle= -angle;
            }
            this.gameObject.transform.Rotate(Vector3.up * angle * Time.deltaTime*RSpeed);
        }

老师,键盘控制的左右方向键转向速度不同是什么情况?两个键控制的角度只是正负号不一样而已啊,但右方向键的转向速度莫名的快很多倍。。。。。。。 

所有回复
发表回复
你还没有登录,请先 登录或 注册!