U3D如何让物体旋转一定角度
2个回答
2014-02-19
展开全部
以相机为例,写入以下代码:public var cm:Camera;//Camera Objectpublic var maxRotationAngle = 20;//Max Rotation Angle each sideprivate var currentAngle = .0;function Update () { var cfAngle = 15 * Time.deltaTime; if(Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) { cfAngle = -cfAngle; } else if(Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) { } else { return; } var newcurrentAngle = currentAngle + cfAngle; if(newcurrentAngle > maxRotationAngle) newcurrentAngle = maxRotationAngle; if(newcurrentAngle < -maxRotationAngle) newcurrentAngle = -maxRotationAngle; cfAngle = newcurrentAngle - currentAngle; currentAngle = newcurrentAngle; cm.transform.Rotate(cm.transform.InverseTransformDirection(Vector3.up) * cfAngle); }
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询