- Home /
2D wheel collider falling through small holes
Hey,
I am having a problem with wheel colliders (I have attached an image showing it).
So, I have a 2D vehicle, and a level made of platforms. There are holes between the platforms, and each platform has a different rotation. The wheels of the vehicles moves fine in the platforms, but when it moves from one platform to the next, it gets stuck in the hole.
So, when the wheel wants to move from platform A to B, it gets stuck. The reason for this is simple. The wheel collider casts a ray down, to detect the ground. But because of the level setup, it cant detect platform B, and the wheel partially moves inside platform B, until the ray detects the hole. When that happens, the wheel collider thinks there is no ground beneath it, and it will fall down.
If I put a sphere collider to the wheel textures, then the wheel simply stops, rather than "climbing" to platform B.
I am looking for a viable solution, where the wheel of the car does not fall down, and able to go to platform B.
Answer by Demigiant · Aug 24, 2013 at 05:19 PM
I never worked with WheelColliders, and from what you're saying, they definitely don't look like a good solution for working with "separated" platforms, given the single raycast.
I would go back to the SphereColliders, which at least make a SphereCast. I tried to replicate your issue, with a wheel coming down a platform and meeting a slightly higher one, and it regularly climbed the new one, if it had enough force. Are you freezing X/Y rotations and Z positioning (I'm assuming you're working in 2/2.5D)? If not, you should do it.
Thanks for the answer!
Yes, I am freezing X/Y rotation and Z position.
I will add more force, so it can climb some obstacles, and see if the resoult is ok.