汽车转向问题

时间:2015-01-21 21:04:25

标签: unity3d

我正在使用this tutorial关注this model。我已经将前轮设置为在Y轴上旋转,因此它们看起来像是在转向。然而,左前方“NSF”车轮并没有在我喜欢的地方旋转。它似乎与Front Right“OSF”相同,只是在旋转时向后和向前移动。 到目前为止,这是我的代码:

pragma strict
var wheelNSF : WheelCollider;
var wheelNSR : WheelCollider;
var wheelOSF : WheelCollider;
var wheelOSR : WheelCollider;
var maxTorque : float = 50;
;
var wheelNSFTransform : Transform;
var wheelNSRTransform : Transform;
var wheelOSFTransform : Transform;
var wheelOSRTransform : Transform;



function Start () {
rigidbody.centerOfMass.y = -0.9;
}

function FixedUpdate () {
wheelOSR.motorTorque = maxTorque * Input.GetAxis("Vertical");
wheelNSR.motorTorque = maxTorque * Input.GetAxis("Vertical");
wheelOSF.steerAngle = 10 * Input.GetAxis("Horizontal");
wheelNSF.steerAngle = 10 * Input.GetAxis("Horizontal");
}

function Update(){
wheelNSFTransform.Rotate(wheelNSF.rpm/60*360*Time.deltaTime,0,0);
wheelNSRTransform.Rotate(wheelNSR.rpm/60*360*Time.deltaTime,0,0);
wheelOSFTransform.Rotate(wheelOSF.rpm/60*360*Time.deltaTime,0,0);
wheelOSRTransform.Rotate(wheelOSR.rpm/60*360*Time.deltaTime,0,0);
wheelOSFTransform.localEulerAngles.y = wheelOSF.steerAngle - wheelOSFTransform.localEulerAngles.z;

wheelNSFTransform.localEulerAngles.y = wheelNSF.steerAngle - wheelNSFTransform.localEulerAngles.z;
}

这是一个模型问题吗?或者我的编码不正确?

图片显示发生了什么:enter image description here

0 个答案:

没有答案