Raycast Vehicle Friction

for my raycast vehicle, since there are no actual physical wheels because it is a simulated suspension, I have to simulate friction. I have figured out how to get the max friction force, but have yet to figure out the force I am actually suppose to apply to the car originally. I am not very good at physics, so if anyone could help me, it would be greatly appreciated.

2 Likes

You can edit the friction parameters by enabling BasePart.CustomPhysicalProperties.

I think that the easiest way is just to play around with different friction parameters.

You missed the entire point. Since the vehicle uses raycasts, its floating off the ground. Friction doesnt work on it since its not touching the ground

2 Likes

Oh my bad. In that case, he will need to calculate the tire friction itself. Tires have rolling resistance (see Rolling resistance - Wikipedia). This can be calculated with:

-- Prevent dividing by 0
local velocityUnit = (velocity.Magnitude > 0) and velocity.Unit or Vector3.new()
-- Calculate the friction force
local rollingFrictionForce = tireNormalForce.Magnitude * rollingFrictionCoefficient * -velocityUnit

This is quite complicated, since the rollingFrictionCoefficient needs to be modeled and can vary depending on the underlying surface. It is possible to estimate the tireNormalForce with vehicleMass / #wheels.

2 Likes

Do I apply this force to the side? Also thank you so much for replying. Wait its a vector correct so I would just subtract from the current force?

The calculated force is a Vector3 that lives in world space. You can make an attachment with a VectorForce (that is relative to world space). Then you can update VectorForce.Force to rollingFrictionForce on RunService.Heartbeat.

Alright, awesome! Also, would the coefficient be a decimal like 0.75 or a much bigger number? Should I just play around with values for each material?

Actually, the coefficient is not a constant. It mainly depends on the velocity and underlying material of the wheel. You will have to model it as a function of these parameters (getRollingFrictionCoefficient(velocityMagnitude, material).

afbeelding

3 Likes