对不起,但我找不到任何有用的资源。 在Unity中,有两个车轮碰撞器A和B,它们有自己的速度值,可以连接到汽车上。这辆车还有另一个带有CarSpeed值的脚本。所以我想要做的是,在车轮碰撞器A和B的速度值之间分配这个CarSpeed值,我希望基于另一个名为AllWheelDriveLevel的值,它决定了Speed是否在所有车轮之间均匀分布。所以,帮助我找到一个算法的方法会有所帮助,谢谢! :d
答案 0 :(得分:1)
你应该能够通过这个例子找出解决方案;
{
public int allwheeldrive = 1;
private List<GameObject> wheels = new List<GameObject>();
private float totalwheelpower;
private List<bool> activewheels = new List<bool>();
private void Awake()
{
int four = 2;
while (four != 0)
{
GameObject wheel = new GameObject();
bool wheelactive = false;
activewheels.Add(wheelactive);
wheels.Add(wheel);
four--;
}
}
void distributepower()
{
float powerwheel1;
float powerwheel2;
switch (allwheeldrive)
{
case 1:
powerwheel1 = (totalwheelpower / 3) * 2;
powerwheel2 = (totalwheelpower / 3) * 1;
break;
case 2:
//fill out what other possibilities u want
break;
}
}
}