请问我在unity给车辆添加下面这个让车轮旋转的代码运行正常
public WheelCollider[] WheelCollider;
public Transform[] WheelTrans;
void Start()
{
}
void Update()
{
float vertical = Input.GetAxis("Vertical");
float horizontal = Input.GetAxis("Horizontal");
for (int i = 0; i < WheelCollider.Length; i++)
{
Vector3 pos;
Quaternion rotation;
WheelCollider[i].GetWorldPose(out pos, out rotation);
WheelTrans[i].position = pos;
WheelTrans[i].rotation = rotation;
}
}
}
但是添加这两句转向的代码,运行后车子就开始抖动了,这是什么原因
WheelCollider[0].steerAngle = horizontal * 30;
WheelCollider[1].steerAngle = horizontal * 30;