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

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?

Humanoid:Sit(VehicleSeat)

Here are some resources that can help with secure handling of vehicles (4 Part Series):

Hi! May I ask how you calculate the wheels turning? I’m currently struggling with the same problem
Thanks!

1 Like

Use the c1 of the wheel welds to modify orientation through lerping

How would I replicate this to other players? since welds aren’t replicated
I know i can send unreliable remote events but im wondering if there’s a better / smoother way (right now i calculate the wheel rotation along its axis by using their speed, which allows for smooth interpolation, im wondering if there’s something simlar for wheel turning)

TLDR, do it individually on each client.

Thanks! That is what I do for the suspension, but how do I know when to turn the wheels for the player? (Ex: When they press A and D)

Like you said, unreliable remotes when steerfloat changes and make it distance based to use least resources.