我在统一制作一个andriod漂移游戏(在c#中),EVERYTINHG在编辑器中100%工作,但是当我在我的andiod手机上构建它并测试它时,当汽车产生时汽车崇敬,所以我做了一些调试并发现当汽车被激活时,所有 4 个轮子 coliders 的 rpm 都会跳到“naN”
代码:
public void Update()
{
GetInput();
HandelMotors();
HandelSteering();
UpdateWeels();
CheckDrifting();
UpdateEffects();
ChangeValues();
ChangeUI();
}
//---Alot of other code, ask if you want to get all the code---
private void HandelMotors()
{
FRWC.motorTorque = (VerticalInput * MotorForce) + (Turboing == true ? TurboBoostAmount : 0);
FLWC.motorTorque = (VerticalInput * MotorForce) + (Turboing == true ? TurboBoostAmount : 0);
FRWC.brakeTorque = IsBreaking ? MaxMotorBrake : 0;
FLWC.brakeTorque = IsBreaking ? MaxMotorBrake : 0;
RLWC.brakeTorque = IsBreaking ? MaxMotorBrake : 0;
RRWC.brakeTorque = IsBreaking ? MaxMotorBrake : 0;
}
生成时停止汽车的代码
void StopCar()
{
CarController.enabled = false;
TrailL.enabled = false;
TrailR.enabled = false;
FRWC.motorTorque = 0;
FLWC.motorTorque = 0;
RRWC.motorTorque = 0;
RLWC.motorTorque = 0;
FRWC.brakeTorque = Mathf.Infinity;
FLWC.brakeTorque = Mathf.Infinity;
RRWC.brakeTorque = Mathf.Infinity;
RLWC.brakeTorque = Mathf.Infinity;
CarRig.velocity = Vector3.zero;
CarRig.angularVelocity = Vector3.zero;
CarRig.drag = 0;
CarRig.angularDrag = 0;
Invoke("EnalbeStuff", 1f);
void EnalbeStuff()
{
CarController.enabled = true;
TrailL.enabled = true;
TrailR.enabled = true;
}
}