Physics Car

Hello guys,

I’m trying to use the Car tutorial style of Raycasting on the wheels but I’ve got this problem visualize on the picture attached…Half of the wheel will sink below the height map generated from Unity…

This will just happen only when I turn the car either to the left or right…

Please advise…

Thanks a lot

It wouldn’t happen if the truck wasn’t American made :smile:

Lolz… seriously, anybody knows why?

Anybody please??

The wheel collider is actually implemented as a raycast, so it can sometimes have unexpected behaviour. There’s an example of how to fix this problem here.

I’m not using wheel collider here, I’m using the Alternative Physics of the Car Tutorial, but since you said that Wheel Collider still uses Raycast so it should be fine…

I’ve tried to add the capsule collider here but it seems that it messes the car more… it’ll flip up uncontrollable…

[/img]

Try this out…

http://www.gemango.com/pub/sedrix/Unity/Raycast.html

You should align the capsules so the two domes are facing sideways out of the wheel (so the circular cross section matches the wheel’s). Also, put the capsule colliders on the Ignore Raycast layer to ensure the raycasts aren’t falsely detecting them as the “ground”.

Thanks a lot… It really helps…

One more question, why is the wheel on the right will be lift while i’m turning towards the left or vice versa… I notice that if the left wheel compresses during turning the right wheel will compress as well… I’m using the Alternative Physics Tutorial…Is it by design?

Please advise…

Is this happening when the car is moving quite fast? If so, it may be rolling because the centre of mass is too high up in the object. Try setting the centre of mass lower from the script:-

var heightCOM: float;

rigidbody.centerOfMass.y = heightCOM;

A good way to tweak this value is to set it each frame in the Update function. Then, you can change the value in the inspector while the game is running. Once you’ve got the right value, remove the line from the Update function and put it in the Start function so it only gets called once. You’ll probably find that a very slight change (eg, setting it to -0.1) will affect the car quite a lot, so be careful not to overdo it :wink: