This may have more to do with constraints than scripting, but I don’t know a better category, since scripting is definitely a part of it.
What I am doing
I am making a car that uses spring constraints and cylinder constraints for each of the wheels.
The car goes pretty fast after a bit of acceleration, but tuning the springs proves to be really difficult, as it freaks out over certain terrain elements. It also either drifts way too much or flips over while turning. I tried adding torque to the body in the opposite direction, but it doesn’t seem to help too much. I am trying not to just do a lower center of mass, as most posts suggest, as I do want the car to be able to flip over, it should just require something like running into a wall or another player and not turning or driving over mostly flat terrain.
Any insight into this? I’ve been tuning the springs, the torque, the turning speed and lerping amount, and the wheel friction and elasticity for hours. Preferably I’d like to be able to solve this with physics constraints, but if there’s something scripting wise I need to do that is fine as well. The most promising thing I have tried is adding a downwards velocity with a relationship to the forward velocity, but this seems to make the car jitter a lot. Another thing I found was a stabilization bar that connects the wheels on real life cars, but I don’t know how to implement this other than the torque I mentioned adding before.
If you’re using real wheels that actually roll on the ground, if the steering geometry is not correct, the car may slip sideways when turning (see Ackermann steering geometry). I implemented a constraint-based car using constraints and the Ackermann geometry and I never had my car flip, much less on a flat surface. It definitely drifts, though – you can try it out here to see if it has the same problems you are describing. It requires some trigonometry to implement correctly, though, and you also have to adjust the torque on the wheels separately. I used the formulas on this website.
One more thing, if you know the exact weight of the car, and if you know how much is distributed on each of the four wheels, you can calculate the correct tuning to ensure your springs are critically damped or slightly
overdamped underdamped, which I believe is usually how it’s done IRL.
I considered implementing this, but it didn’t seem like it would make much of a difference. I’ll look at your game to see what it feels like, but I’ve definitely seen cars that don’t use it work how I’d like. Thanks!
I’ve had some experience with this: Tracked vehicle, suspension and racing tests. - Roblox
Are your wheels MeshParts, Unions, Cylinders or Spheres?
Cylinders and Spheres are your best options for wheels. MeshParts and Unions are not as smooth and usually make the wheels hop. You can see this if you use the ‘rough’ wheels on the buggies or truck on the outer smooth track in my test place. I designed the rough wheels to be better for gripping smooth surfaces while climbing steep grades.
Increase or decrease the Damping on your springs to tune them to your vehicles mass, sprung weight (chassis) and unsprung weight (wheels and suspension Parts). If I remember correctly this is between 5 and 200.
Increasing the Density of your wheels can increase the traction as well as the bounciness of your unsprung weight. I usually max it out at Density 2. It also helps lower the center of mass to keep it from flipping, but it will flip.
I use ackerman steering as @suremark said, but I don’t calculate it. You can see the pivot point of the steering link on my truck & buggies and the angled steering arms on each wheel. Steer and you’ll see how the inner wheel steers more than the outer wheel. I just use trial and error at slow speeds to set it up to what looked ‘right’.
And what exactly are you lerping?
Thanks for the suggestions. I’ve been using spheres as the wheels. It seems like your cars mass is way lower than mine, by a lot. I set my wheel density and car density really high to try and keep more downward force on the car and it seemed to stabilize it, compared with making it lighter which had it flip even easier. It sounds like this is working for you, though, so I may give it a try. I’ll look at your place and try the Ackerman steering, but again I’m not sure that’s the issue as even going straight the car sometimes freaks out when a wheel gets stuck on a miniscule terrain triangle.
Here’s an update for anyone who finds this post later. Me, @suremark, and @Scottify tried out some stuff. Me and suremark were talking online and exchanged formulas for dampening and stiffness. This all worked fine, but bumping was still an issue, until I increased the spring length. However, this made the car top heavy, so I also raised the attachment height:
I also decided to just fold and go ahead and add an invisible part that’s really heavy and low. It’s not too jarring since it’s between the wheels.
As it turns out, the springs simply weren’t long enough to support the car.
Hehe, and blasting around in suspension vehicles with you and @suremark was a lot of fun!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.