Members

Wheel collider help

I am trying to create a racing game but I have a hard time understanding the fundamentals of using the wheel collider. Can anyone help me out with a step by step procedure about how I should get started with this?

Thanks! I've actuallt tried both of them already. Someone told me that they tried jcar as well but that I shouldn't use it since it's jacked up.
I guess I'll just have to go back through them again and see how much I can get out of them since those are the only two that seems to be around.
Thanks again though.

I have tried my own little project where I created a simple car. I used the cube for the car body together with 4 cylinders for the wheels.

I have created 4 wheel colliders separately from the wheels by creating empty game objects and applied wheels colliders to them.

I have applied the player car script from the example project to my simple car. It doesn't work. I know I am doing something wrong that's why it's not working. Can anyone shed some light on this subject for me?

Unity Technologies

I've attached a project with a very simple demo of a car made with wheel colliders. The key thing to note about these is that they don't really have a physical volume like most other colliders. They are actually implemented by measuring the distance to the ground and applying an upward force to simulate what the wheels would be doing (a bit like a carefully controlled rocket thruster in the position of the wheel).

You shouldn't rotate the colliders around the wheel axle to make the graphic rotate because this results in the "thruster" getting pointed in the wrong direction. However, you can steer by turning the collider object left and right around the Y axis. The calculation to convert the collider's RPM value into a rotation angle is straightforward and is noted in the code.

The centre of mass on the rigidbody often needs to be lowered slightly to make the car stable while turning. There are also many other nuances you can add to give better handling or otherwise make the car more suitable for your gameplay.

Attached Files:

Thanks a handful mate, your concise response and helpful code is exactly what I was looking for!! I'm relatively new to the site but you seem to pop up all the time - in the right places, for me anyways. I hope you're getting rewarded for your efforts! I may start a fan club for you