WheelCollider Sliding over terrain

www.splatsosoft.com/misc/wheelcollider_problem.mov

The link above shows a video of the issue. I have a robot with 4 wheel collider wheels with the default configuration for friction. When the vehicle touches down on startup it begins to slide across the terrain. The reported RPM for each of the wheels is 0 and brakeTorque is being applied. Any ideas on how to stop this?

Thanks!

Any ideas on this one? If I set the mass high enough the problem disappears, but then the mass of my model isn’t correct anymore. Oh and I fixed the video upload, it was corrupted, now it won’t crash Safari. :smile: Sorry about that.

i don’t know if there’s a built-in way to stop this, but maybe just have a script that sets the friction high if there’s no user input velocity is below a certain value?

i’m not on my computer i can’t look at your mov file for some reason but i’ve noticed this behavior as well (even on perfectly flat surfaces).

PhysicMaterials don’t effect wheelcolliders.

Maybe your scale to mass ratio is really off (ie, all of your objects are extremely huge, but you’re using realistic masses for everything)? Maybe if you try scaling the whole scene by say .01?

That’s the only thing I can think of.

Based on the size/distance from camera ratio, I don’t think this is the problem. Everything is created in Cheetah3D. The wheel colliders are set to a radius of .15, which is the correct size in meters. The mass of the vehicle is 50 (which I assume is measured in kilograms… yes i know it can be what ever units I want, however I would expect the physics engine to use SI units) and the mass of each wheel is 3. These are all nearly true to life masses and sizes. I just tried making the model both larger and smaller, this exaggerates the problem significantly.

Mass is only relevant compared to the mass of other objects. So no, it’s not kilograms, it’s just a relative measurement. The size, however, is 1 unit = 1 meter in physics terms, and does affect how individual objects behave. You can give your vehicle a mass of 1 or a mass of 1000 and say either one is “50kg” and it makes no difference at all; just make sure other objects have an appropriate mass by comparison. Doesn’t sound like any of that is the problem in any case…

–Eric

wouldn’t this be a drag issue? i don’t think mass is the culprit. mass is more for inertia calculations afaik.

I don’t think it’s a drag issue. If I swap the WheelCollider for a RaycastCollider it sits still, however then I loose the collision detection around the circumference of the wheel. I think there may be some issue/bug with the wheel collider. If I don’t resolve this in the next few days I’m going to submit a bug report. This only is an issue when Use Gravity is enabled. If I disable gravity for the object after it hits the ground there is no sliding, so I think it has something to do with how the slippage on the wheels/object is being calculated within the WheelCollider.

OK it seems that applying the brakeTorque or motorTorque prevents the rigidbody from sleeping, this kind of makes sense. However, if the brakeTorque is not applied every frame the vehicle will roll down hills when it should actually stop. After the vehicle stops it slides very slowly (< 1 mm per second) backwards on a flat plane, or in the direction of a terrain slope. So some forces are not being calculated exactly correctly maybe. While this may not be an issue in a game where a vehicle is always in motion such as racing, it is an issue where the vehicle may be sitting still for a while as obviously it could slide somewhere it shouldn’t or in my case a simulation of a vehicle looks dumb if some of the robots start drifting over a flat surface. So anyway I’ve filed a bug report (16193) with a small example project of the vehicle on a cube.

Jeff, did you allready get an answer about this ?

No, I filed a bug and that was the last I heard. I’ve switched over to making a nice GUI at the moment while waiting to hear back.

Any resolution to the filed bug 16193? Where one can see the reported bugs?

No, I still run into the problem every now and then. I’ve been working around the issue by forcing my objects to sleep when they go below a certain velocity magnitude. The physics system is supposed to do this, but when you keep applying forces as an active brake the object doesn’t go to sleep. Now I’d think that the object shouldn’t slide regardless, but it does. In some cases if you tune the friction parameters of the wheels you can reduce the sliding, but I’ve never eliminated it.

I’m seeing the same issue as jeff: When brakeTorque is being applied constantly in FixedUpdate, the vehicle will very slowly drift.

Simple to reproduce:

  1. cube + rigidbody: mass 200, drag 0, angular drag 0.05, use gravity, interpolate.

  2. Add wheelcolliders at the corners, as you would normally when making a car. Leave the settings at default values.

  3. Set the vehicle in a flat collision surface.

  4. Put a script on the cube with the following:

var wheelBackRight : WheelCollider;
var wheelBackLeft : WheelCollider;
function FixedUpdate() {
	wheelBackRight.brakeTorque = 90;
	wheelBackLeft.brakeTorque = 90;
}

So rather than getting full stop when the vehicle is standing still, you get that slow drift.

The reason I use the above brakeTorque is because I apply that when the player lets off the gas pedal so the car will slow down. This works fine except when the car is at full stop (then you start to see the drift).

BTW, I’m using Unity iPhone v1.5

BUMP. This slow drift is making my drag racing game look like ass. If you just let the cars sit still for a couple of minutes they’ll drift off the track and onto the UI.

I’d really rather not have to resort to putting up collision to keep them off the UI, since they’ll still be drifting on the track until they hit the walls.

I’ve tried increasing the Drag which seems to stop them for a while, but then before long they’ll slowly start to drift again. So that only postpones the problem.

I looked into rigidbody.Sleep() and found a solution that works (for me at least).

Check the RPM of one of the wheels, and if it falls below 0.1 (for example), then put the rigidbody to sleep. Example:

var car : RigidBody;
var wheelBackRight : WheelCollider;
var wheelBackLeft : WheelCollider;
static var gasPedalDown : boolean;

function FixedUpdate() {
	wheelRPM = wheelBackRight.rpm;
	if(gasPedalDown) { // apply gas (bool set in gas pedal control script)
		wheelBackRight.motorTorque = 10;
		wheelBackLeft.motorTorque = 10;
	}
	else { // apply brake
		if(wheelRPM > 0.1) {
			wheelBackRight.brakeTorque = 5;
			wheelBackLeft.brakeTorque = 5;
		}
		else {
			car.Sleep();
		}
	}
}

Was this ever resolved? I have encountered the exact same problem and am having to force the object to sleep in order to prevent it from sliding…
Thanks in advance!