我试图更改组件中的值,但它不起作用,这是我的代码:我尝试初始化方法外部的变量,但它给了我一个错误,因为我首先初始化了车轮碰撞器(FDW,FPW,BDW,BPW) private void Slip(){ //FPW, FDW, BPW, and BDW are all wheel colliders float stiffness1 = FPW.sidewaysFriction.stiffness; float stiffness2 = FDW.sidewaysFriction.stiffness; float stiffness3 = BPW.sidewaysFriction.stiffness; float stiffness4 = BDW.sidewaysFriction.stiffness; stiffness1 = 5; stiffness2 = 5; stiffness3 = 5; stiffness4 = 5;}private void OnCollisionEnter(){ Slip();}
1 回答
米脂
TA贡献1836条经验 获得超3个赞
WheelFrictionCurve是一个结构体,所以如果你想改变它的属性,你需要:
var curve = FPW.sidewaysFriction;
curve.stiffness = 5;
FPW.sidewaysFriction = curve;
- 1 回答
- 0 关注
- 109 浏览
添加回答
举报
0/150
提交
取消