I am currently developing cars for a game. While many top games (e.g. Jailbreak) use raycasting to simulate suspension, I prefer to use constraints, as this avoids the issue of having to simulate friction manually. Overall, I am quite pleased with the results.
However, some limitations come up. The most glaring issue is Roblox’s formula for part-to-part friction. This formula is too limited to achieve a wide range of friction coefficients across different materials. For example, here is a list of friction values I want to match, for the material of my car’s tire:
Friction values
- Asphalt: 0.9
- Concrete: 0.8
- Pebble: 0.6
- Sand: 0.6
- Grass: 0.68
- Snow: 0.2
- Ice: 0.1
Using a nonlinear regression (a-la weighted Gauss-Newton), the best I could do was set Friction to roughly 0.95 and FrictionWeight to 0.38, which gave the following results:
Actual friction values
- Asphalt: 0.89
- Concrete: 0.84
- Pebble: 0.55
- Sand: 0.53
- Grass: 0.55
- Snow: 0.48
- Ice: 0.12
This is pretty close, but the value for snow is quite far off. Adjusting the weights to favor snow more just throws the other values off by 0.1 or more. Anyway, I think this is a pretty reasonable list of values to aim for, but we can only match it to a limited degree.
More importantly, I shouldn’t have to resort to a procedure like this just to control friction across different materials. There should be a way to tune friction values independently for different pairs of materials. A simple override would be just fine.
Secondly, Roblox’s physics engine doesn’t differentiate between static and kinetic friction. This has ramifications for cars, because in real life a sliding car has less traction than a car whose wheels are not slipping. In particular, if your car is sliding, common wisdom says to steer in the direction you’re sliding instead of braking.
An example more relevant to video games would be drifting: if your game includes drifting as a feature, ideally you’d want cars that have good traction but can drift well. However, since there is no difference between static and kinetic friction in Roblox, it is impossible to change drifting behavior independently from non-slipping behavior. The more grip your car has, the less able to drift it is.
The only way to circumvent this that I could think of would be to detect sliding, which is probably difficult to do for anything besides a flat surface. I can’t imagine using raycasting to detect if a tire starts sliding on rocky, mountainous terrain with a large number of triangles.
These are my two main issues that I’ve ran into while developing vehicles on Roblox using constraints. While these issues can in principle be circumvented with custom-made solutions, these solutions are less-than-perfect and involve considerable effort on the part of the developer.