Custom Wheel Collider in Unity3D banner

Custom Wheel Collider in Unity3D

6 devlogs
14h 32m 1s

Making my own custom Unity WheelCollider using meshcasting methods instead of the default WheelCollider and ray casts methods which are often times unrealistic and unsatisfying.

This project uses AI

Used Gemini for code reformatting for better readability

Demo Repository

Loading README...

msw

Tagged your project as well cooked!

🔥 msw marked your project as well cooked! As a prize for your nicely cooked project, look out for a bonus prize in the mail :)

LampDude

Shipped this project!

Hours: 14.53
Cookies: 🍪 390
Multiplier: 26.85 cookies/hr

I just built Robbie Vehicle Physics, a custom Unity Vehicle Physics system with custom wheel colliders (not using Unity’s built-in ones). My biggest challenge was implementing a multi-contact Mesh Sweep system from scratch; because there is very little resources on how to use SweepTestAll for vehicle wheels, I had to create my very own solution to handle it which I am SUPER proud of. I’m also particularly proud of how the system processes multiple collision points to maintain suspension stability on complex geometry, far surpassing the jitterness often found in standard Raycast implementations. To make tuning easier, I also learned to build a custom GL-based debug system that visualizes wheel outlines, hit normals, and suspension compression in builds which normally you would only see in teh editor.

LampDude

Overhauled the system, previously, the wheel collider only supported one contact point, which meant that when the wheel is wedged between a gap, it would flicker. now with a few changes like using Sweepcastall instead of just sweepcast, the wheel can now have multiple contact points at the same time. I also overhauled the gizmos system with a little help from AI adding suspension meters, contact points, and a more robust gizmos system overall.

Attachment
0
LampDude

I THINK I COOKED!!!! Finally completed suspension AND traction. By applying Hooke’s Law, my system now calculates upward forces using spring stiffness and damping to simulate weight and shock absorption, this took me so much time to figure out how to make it and how to make it work with my sweepcasted wheel instead of the traditional singular raycast. I also added a arcade traction system using a friction curve to balance steering. It’s almost complete! I just need to make it look nicer (custom editor maybe???) and make my code presentable (it looks kinda messy rn)…
But this is a huge milestone! I’m very proud of what I’ve achieved :)

0
LampDude

Basic wheel collision finally works! Now it goes up bumps and ramps like expected, it just doesn’t have suspension. I’m avoiding suspension right now, It’ll probably be the hardest part…

Attachment
0
LampDude

I have successfully set up the gizmos and started to test out my rigidbody.sweeptest! Its not perfect as there is no collision yet but it detects the wheel I have configured correctly. It’s a huge step in achieving a better and more robust wheel collider.

Attachment
0
LampDude

Setting up the testing scene and importing a car model into unity URP! This car would surely fly sometime when im developing the wheel collider…

Attachment
0