Raycast Car Sliding Friction Bug

Hi, I’ve been coming across some issues with my raycast car

  1. What do I want to achieve?

Implementing sliding friction into a raycast car so that it does not slide sideways. (Perpendicular to each thruster)

  1. What is the issue?

The car spins out of control if I turn too much. You can see it in this video below:

(Note: If you have difficulty loading the video, try opening it on youtube)

  1. What solutions have I tried so far?

I have searched the forums for a possible solution, and while there are some topics similar to mine, their solutions have not worked out for me. I believe that my system is very close to working, but there’s something small preventing it from working.

Upon extensively testing my own system and visualizing the vector forces, I believe it’s a direction problem and not related to magnitude of the force. Decreasing and increasing the mass or grip factor only makes the spinning faster or slower. In my video, you can see that as soon as the vector force arrow points backwards, that’s when the spin happens. Also, I am using torque to turn/steer the car.

I would appreciate any help or guidance. If you need more information, let me know.

5 Likes

Try applying a force in the opposite direction, this may help you a bit.

That’s what I am trying to do. If you check the code, the xF variable is essentially the friction force preventing the car from sliding sideways.

The spinning behavior caused by this friction force is what I am trying to fix.

what’s the * 1 supposed to do?

It’s the mass. Changing it does not solve the problem. I’ve tried.

Sorry for reviving this but have you ever fished out a solution? I’m experiencing something similar since switching to VectorForces for my vehicle

Yo! I saw this tutorial in February and got tempted to try it. I always wanted to try making a Raycast car because of some issues I had with constraint ones. But anyway.

The only solution that worked for me the most was this one:
Raycast Vehicle Friction - #4 by Brickman808 .

I had to make some changes because it didn’t work with VectorForce, for some reason. It also is not perfect.

This is one of the reasons why I prefer constraint chassis because I only have to deal with physics in a practical and somewhat realistic way. No calc.

The code I’m using:

local VelocityUnit = (SpringPosition.Magnitude > 0) and SpringPosition.Unit or Vector3.zero
local RollingFriction = Raycast.Normal.Magnitude * script:GetAttribute("TireGrip") * -VelocityUnit

VehicleRoot:ApplyImpulseAtPosition(Vector3.new(RollingFriction.X, 0, RollingFriction.Z), WorldPosition)
1 Like

Huh, using the raycast normal is something I have not seen yet. I’ll try this out tomorrow! Thanks for your effort in replying to this post.

1 Like

Hello, It is me again. Can you explain what you VelocityUnit is, and you spring position? Is that the position of the wheel, or the length of the spring as a vector. I’m trying to work with the math and experiment on my end. Thank you in advance.

So I managed to solve this issue. It seems almost silly now. All I had to do was change the property of the vector force to be relative to the attachment rather than the world.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.