WheelColliders stiffness and c#

I’m trying to modify the stiffness of my wheel(s) so I can remove friction from them when needed.

	private void removeWheelFriction(){
		foreach(WheelCollider wheel in wheels){	
			
			WheelFrictionCurve sf = wheel.sidewaysFriction; 
			WheelFrictionCurve ff = wheel.forwardFriction;
			ff.stiffness = 0;
			sf.stiffness = 0;
			print("wheel"+wheel.sidewaysFriction.stiffness);
		}
	}

Does not actually change the stiffness… it still comes through as the default value of 1.

doing:

wheel.forwardFriction.stiffness = 0

returns and error that I cannot modify the return value because it is not a variable.

How do I get this to work in c#?[/quote]

1 Like

Never mind… I thought I had tried this already… but this works:

	private void removeWheelFriction(){
		foreach(WheelCollider wheel in wheels){			
			WheelFrictionCurve sf = wheel.sidewaysFriction; 
			WheelFrictionCurve ff = wheel.forwardFriction;
			ff.stiffness = 0;
			sf.stiffness = 0;
			wheel.forwardFriction = ff;
			wheel.sidewaysFriction = sf;
			print("wheel"+wheel.sidewaysFriction.stiffness);
		}
	}
1 Like