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

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

1 Like

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.

Yee, I’m aware that the wheels are fake, I just thought you would turn the wheels using Weld.C0 orientation. Changing direction of car will be angular velocity though

Oh yeah forgot, you can also do that aswell just wanted mine to have some sort of transition.

Can you please show me how you turned your wheels? I tried Weld.C0 but since the actual rotation of the wheel depends on it, it sort of compiles on top of each other and makes a wobbly wheel.

EDIT: nevermind, had to do weld.c1 not c0

ive made my own raycast suspension car a while back but it came with a lot of issues

have you checked for fps drops, does the car freak out/fling at low fps (or lag spikes)

also is the raycast only one ray? since this would make it so only when the center of the wheel is over the target, it will move it up

ideally you want to create body forces depending on which drive mode your car has, all wheel drive, rear wheel drive, etc. turning the wheels would require changing the direction of the force from the front two wheels to that of which the wheel points. And as far as drifting, it basically occurs when the rear wheels slip. To simulate this, disable the rear wheels drive component to where only the front two wheels have control and you will achieve drifting.

2 Likes

Hey man, thank you so much for all the help and I’ve got the vehicle working quite amazingly on the client side. I saw your recent YT short about hitting NPCs with cars and noticed that the suspension & wheel rotations weren’t replicating to other clients, a bug I am also facing. Is there some way to fix this?

you could make a cache of all cars and make it so a script looks through the car and sets the wheel rotation according to the vehicle’s velocity

1 Like

Will the script be on the server? Would it be inefficient to just send a remote event to the server with the wheel rotations of the client?

It would be highly inefficient to use remote events for this.

Make it a client script in StarterPlayerScripts, and have it look through all of the cars.

Something to note is that if you have StreamingEnabled on in your game, it could lead to issues so make sure to accomodate for that.

A good way to go about this is tagging all vehicles via collectionservice, and then on the client using CollectionService:GetTagged("Vehicle") or some iteration of that.

Hope this helps.

1 Like

So it will be based on the client’s perception of other players’ car’s speed? And based off that spin the wheel. I think that’s a good way, it would allow me to have distance based replication as well. Thank you so much for your help :smiley:

1 Like

Works like a charm, I simply used the same module to start calculating other players’ wheel turning & suspension, works super smoothly. Of course, I’ll make it distance based so there’s no unnecessary calculations running. Thank you for your help @LeehamsonTheThird & @dayflare!

Hello, may I ask how did you make the vehicle seat work?