I have a problem with my car setup and height increasing or decreasing roads. The wheels are dispersing every time a little more inside the mesh after after the wheel collider starts to collide with the next face of the track.
I already tried to subdivide the road in blender. The poly count got much higher but the problem still persist.
The setup don’t shows this behavior on a flat track.
I’m using the following code to position the wheels:
void WheelPosition()
{
int i = 0;
foreach (WheelCollider w in wheelColliders)
{
// define a hit point for wheel collision
WheelHit hit;
Vector3 center = w.transform.TransformPoint(w.center);
if (w.isGrounded == true)
{
w.GetGroundHit(out hit);
Vector3 temp = wheels[i].position;
temp.y = hit.point.y + (w.transform.up.y * w.radius);
wheels[i].position = temp;
}
else
{
Vector3 temp = wheels[i].position;
temp.y = center.y - (w.transform.up.y * w.suspensionDistance);
wheels[i].position = temp;
}
i++;
}
}
wheel radius is correct for your wheels?
GetGroundHit is also working correctly? (Debug.DrawLine helps to identify such issues straight in the editor)
and the physics settings have been made correspondingly for it? (I guess that might most likely be it as the performance you have on the iphone is significantly lower and mesh collision is commonly avoided for the good especially if you have that many polygons as you have there)
The wheel collider radius is set for all wheels equal to the radius of the wheel graphics object(in my case 0.49).
For the car I’m using two box colliders in combination with a Rigid body. I removed the default mesh collider from the main body of the car.
For the track I simple created with the import function an default mesh collider. Would it be better to import the drive track in separate meshes with custom made box colliders? I found an article to automate this process somewhat. http://www.anicombo.com/blog/?p=404
I lowered the default timestamp from 0.02 to 0.033. This setting will give my demo app a smooth 30 frames.
I will try to debug this when I’m back home. The current setup works ok on the flat parts of the track. For now I’m guessing that the GetGroundHit function is working correctly.
(ie, it’s not just the Y coordinate of the point that is significant.)
Secondly, make sure that the positioning of the wheel graphics is done in the LateUpdate function. You want the physics effects to be applied before you get the hit position to move the graphics.
I tried the given suggestions but it introduced some other problems :(. Anyway I’m trying to upload a compressed zip project of 4.7 MB. I got an error message “Tried to upload empty file”.
I dropped the whole wheel collider set-up. It’s given me tons of problems on none flat terrain with an high speed car. I started two weeks ago with this project:
After implementing the code from the Forest Johnson blog I realized that a wheel collider set-up shouldn’t make that match difference. I have combined some of the RayCast car code and JCar inside my test scene. The only problem I still can’t fix is that the car starts to bounce over edges between triangles in combination with a low poly track.
Please help to resolve this last matter for my basic wheelcollider arcade race car set-up.
I tried the last two weeks lots of different settings. I didn’t manage to fully neutralize this behavior with different wheel collider spring/damper values. I have limit the car’s velocity to 352 km/h. The engine should in my opinion be able to handle that kind of speed. I have no problems that the car is going trough meshes. I’m now thinking about to implement an extra joint for every wheel that will eliminate (clamp) the shock from the edge.
Another possible solution to this problem is discussed on GameDev sphere triangle edge collision issue - Math and Physics - GameDev.net. I’m not sure this problem is also related to Unity but the behavior described looks the same in my test scene. Is there some way in Unity to get the bounds of the current plane that the wheel colliders is hitting (Mesh.bounds)? I want to check if the hit.point is on an edge and then try to change it to a position after or before the edge.
One remarkable thing I noticed is that the hit.force value will drop to zero if the collider is going through an edge.
On the Nivida forms there is also a suggestion to check smooth sphere collisions. It didn’t make any difference.
I also have written some simple logic for the suspension spring target position. The result is that the car will not flipping easily over anymore. My whole collider set-up is fully scripted but exact the same problem will happen with manual installed wheel colliders.
Please check the scene out if you have some Unity spare time left.
I have a problem with my car setup and height increasing or decreasing roads. The wheels are dispersing every time a little more inside the mesh after after the wheel collider starts to collide with the next face of the track.
I already tried to subdivide the road in blender. The poly count got much higher but the problem still persist.
So,Please Send Me The Step by step process for this Problem