Raycast Suspension Wheel Module | An alternative to standard physics based wheels

Background

Hello everyone, Almost a year ago I was trying to make my own raycast suspension system for a car chassis because I found that making vehicles with roblox physics is way to complicated so I opted to make my own raycast suspension system because it seemed to be faster and looked way cooler. However, I found it incredibly hard to code as there were not many resources on roblox about it. But after a lot of research and revisions I would finally like to present my module to you all.

Where do I get it?

You can find the source code here: GitHub - LeehamsonThe3rd/raycastsuspensionwheel: An easy to use ROBLOX module that allows for wheels with raycast suspension instead of the standard physics based wheels

How does it work?

Basically the car shoots a raycast down onto the floor and depending on how close that ray is to the floor the more suspension force is applied upwards. However this will make the car continuously oscillate, to prevent this I added damping to the system so that the forces even out. With all of this combined you will have what appears to be a floating platform, slap a car body and some tires on it and you will have yourself a car!

Here’s a video I made on the system

Some resources I used

These are just some videos, but there are some other resources I unfortunately don’t remember the links to

59 Likes

This is absolutely gonna be useful for anyone that’s planning for creating a game with cars, thanks for sharing it :smiley:

7 Likes

I tried using the module to rig a car up in my game, but I do not completely understand the documentation example. This is what the rig looks like
RobloxStudioBeta_Q6qVHZs14E
each wheel has the same attributes
RobloxStudioBeta_f36q3lf3tx
and there is no errors
and I just copied and pasted the example code but nothing seems to happen:
RobloxStudioBeta_RPvrD1OvJC
do I need to set the parts in the motor6D object?

1 Like

there are some internal errors i still have to get around to fixing so as of now this module isn’t currently usable. Sorry for that.

2 Likes

Is there any update, or still broken?

I did fix it actually however if all the vehicle wheels aren’t level it will cause problems, the friction forces also aren’t perfect.

1 Like

is the github link updated? or still broken

Yes, I did update the github repo and changed the instructions and documentation around. I was just stating before the known problems I can’t work out.

so is this updated? can I use it now?

It is updated and you can use it now.

1 Like

I followed the instructions, but the module is not working, and doesn’t output anything also

it appears you did your welds wrong, so perhaps look into that.

1 Like

I can’t get it to work either. It looks like everyone followed the instructions exactly, however.

I apologize, i uploaded the wrong file, check out this example for further assistance
vehicle(1).rbxl (65.3 KB)

5 Likes

Much appreciated! I understand it now.

i know this is quite an old post but… i really never scripted any cars so… how he heck do i make the car move and turn with the player sitting in it? raycast suspension based cars are hard to work with to be fair

Hey, I rigged my car like you suggested, but for some reason, after a certain extent of height, the car just falls through the floor. Right car is mine, left car is the one you rigged. Did you face this issue when rigging your car?

I did adjust the density of the chassis part and the lower it went, the more height the car could sustain, yet when the car falls face front, it still goes through the floor.

EDIT: I Solved it. Apparently it also requires a body with cancollide on.

Yeah the body has to have cancollide on. Also does yours drift away when it’s not moving? I found out that if you calculated the physics on client with networkownership things are different

It doesn’t drift, it sorta rolls away. I just increased rolling friction to stop that. As for client ownership, i let it calculate once the player enters the car.

Have you figured out how to turn the car? With wheel turning?

The actual car is not driven on wheels, rather than the physics that are assisted by the wheels. Turning the wheels won’t do anything, even how the wheels are spun is just fake velocity. However if you wanted to make it go forwards and backwards just change the vector velocity under them. If you want it to steer, you’ll have to stick with changing the angle of the body itself either using cframe or assemble angular velocity - you can also do the same with the wheels to mimic that effect.