# Using WheelCollider to move a car over extremely bumpy terrain

Problem:

Moving a vehicle over terrain that is extremely bumpy, think "4WD Cross Country" style driving.

The WheelCollider requires a connection to the ground for the torque to be applied as a force on the rigidbody. What if the connection with the ground is being made to the circumference of the WheelCollider but not the raycast which determines whether the connection is being made?

The image below shows the back tire of a car actually hitting the ground but the wheelcollider cannot detect this due to the raycast pointing straight down.

Possible Solution

Can I use a sphere collider (set to trigger) to tell the wheelcollider when the ground is being detected (or some how trick it?) ???

I know the physics would be out since a slope would act differently to forces but that can be hidden by changing the stiffness of the wheelcollider.

Any suggestions?

That doesn't happen with Unity's wheel colliders. Instead you have a different problem: basically, the wheel colliders will sink into the ground up to the point where the central raycast position is in contact with the ground. This is better in a way than the problem you speculate, because it's more a visual problem rather than a functional problem - you won't have the problem where wheelcolliders don't detect ground that they're colliding with. Instead, they fail to detect ground that they're sinking into if it's a slope.

So in your case, the tyres will be sunk into the ground on each side of the slope, with the absolute lowest level of the tyre (the bottom middle point) being at the ground surface. This means that the tyres will detect contact with the ground they're riding over, but will sometimes intersect and overlap with the ground geometry to a certain extent depending on the steepness of the slope.

You could try solving this using other types of physics colliders depending on just how accurate you need this to be. Now that you know it always detects ground, you may decide that this is accurate enough. (For example, will there be camera angles such as a close enough side-view which show up this visual problem to a significant extent?) I used plain wheelcolliders like this in an "offroad training" game I made earlier in the year, and it was entirely sufficient from a physics point of view, (but you couldn't actually see the wheels at any time!):

If you decide to "roll your own" wheel colliders ( excuse the pun :D ) there are two main options:

• Make a better raycast-based version
• Make a rigidbody-based version

If you go for the 'better raycast' option, you could perhaps cast a number of rays radially out from the centre point of each wheel, and combine the results of any which hit ground.

If you go for the 'rigidbody' option, it's worthing bearing in mind that it's usually not a good idea to actually try and spin the rigidbody which represents the wheel (it tends to be too fast for the physics engine to simulate correctly). Rather, you should make it slide across the ground freely, and implement the forces related with the tyre contact yourself.

If you do go for either of these options, you'll have to implement suspension and the tyre-contact-patch physics yourself which is no small feat, so good luck!

I had the same problem and switched to an custom based raycast version. Look into this thread at my answer. It will provide you with an complete demo project.