Stop Skidding By Cutting Movement On One Axis

Center of gravity for the vehicle is the center of every parts gravity summed up and divided by the number of parts. Assuming all the wheels lay on the same plane (suspension and wheel deformation are not a factor) and each is touching a surface then each wheel takes a portion of the weight proportional to their distance to the center of gravity. So each wheel’s weight is:

vehicleWeight * wheelToCenter / allDistancesToCenter

The forces should be applied at the point of contact between the wheel and surfaces. Normally, this is directly below the tires in vehicle space. I’d put an attachment on each wheel or multiple on the vehicle and offset them to match these contact positions.

edit: I wonder if Roblox calculates moment of inertia… I think so. These calculations may be a bit off because of that.

Why do the forces have to be applied at the center of gravity??

Also the vehicle rotates somethings even though the friction works, any idea why?

Because imagine the car had its two left tires on a steep slope, its front right in the air, and the back right caught on a surface jutting out. In this extreme case, the front of the car would fall, the back would remain, and the car would rotate counter clockwise. This is because the force from the back tire is being applied at the tire, and the friction forces (which are not strong enough) on the slope are also being applied at the tires but the force of gravity for all intents and purposes is being applied at the center of gravity. Since the force on the back tire is not at the center of gravity, some of it becomes torque. This is proportional to the distance to the center of gravity and the moment of inertia around the axis orthogonal to the force’s position to the center and the force’s direction.

There is a reason only geniuses (like Roblox’s CEO, David) dabble in physics engines!

So, to sum it up, apply the forces to each tire the the problem should go away. Hopefully moment of inertia doesn’t play too big a role or I’ll have to go digging through my physics books again.

I realized that the code we’re dealing only deals with the forces that are applied on the car through anticipation.

We detect what part it’s over and calculate how much force it should apply on the car. Then we counteract it.This works fairly nice.

However, it doesn’t work for forces that are being applied on the car by other means (ie VectorForce or BodyForce), if that makes sense.

Tell me if you understand what I mean.

Yeah, but isn’t that desirable?

Not saying that theres anything wrong with it.

My next goal is to restrict the friction only on the sides of the wheels. So any slope can make it slide forward or backwards but it will need to be steeper if it wants to move it perpendicular to the rolling direction.

So that pulling force, the weight - the normal force, can be split into another two components by projecting on the vehicle’s movement direction, and the pulling force - that projection. That second component can be used for sliding/static friction and the first for rolling friction.

I plan on having no rolling friction in my game.

I know in real there’s a ton of factors when it comes to physics though.

Ok! I got it to only apply friction in the direction perpendicular to the wheel.
Now I know that cars use friction to turn. I’m applying forces on the wheels. So to make it turn using friction like in real life, I’m guessing I just have to apply it to the VectorForces I’m applying on the wheels?

Right, when the wheels turn then the “forward” direction of your turning wheels changes. The projection and corresponding rejection (that was used for friction) of the pull force will change for those wheels. In addition to the pull force though, the current velocity will also have to be taken into account and friction applied to stop that over time according to the amount of force friction can apply.

Turning finally introduces another issue – torque. Torque is calculated by finding the vector from the center of mass/gravity to the point the force is being applied. Then, the projection of this force into that vector remains a linear force (going through the center of gravity) and the rejection becomes torque.

The amount the torque speeds an object’s rotation is determined by the moment of inertia for the direction of the spin. Think of it like mass for rotations. Unlike mass, every direction you spin an object has mass at different lengths from the axis of rotation and so each rotation has a different moment of inertia. I’d recommend using a constant moment of inertia to start, and you can mess with it later if you want.

1 Like

I guess what I’m trying to ask is that the centripetal force equation is to calculate the force pulling an object to the center of the circle, assuming the object is already moving around a circle.

What I’m trying to do is find a way to apply forces to each wheel (4 wheels total) such that they naturally circle around a center point.

I already know I have to find a center point, which I did through Ackerman Steering.

Actually, by implementing friction properly, you don’t need to do this. The force keeping the tires towards the center of the circle is the static / kinetic friction force on the tires. If you simply change the tire directions when calculating the friction then you will get the desired behavior for free.

Thats exactly what I’m trying to go for, unfortunately I’m stuck currently :frowning:

https://i.gyazo.com/a0fc8f1d2e1c72c2a5d867be382470e0.mp4

I applied friction already, but this is not based on the car’s currently velocity. This is based on the forces that I know I applied to it through vector forces. I also have no friction in the direction the tires are facing, just to simplify things I little while I’m working on steering.

Something tells me that it might also be the way I’m applying the forces to each wheel. I’m applying 2500 Newtons in the direction the wheels are facing. My car is four wheel drive.

Each red arrow is equal in magnitude. Hope this is relevant information to my problem.

I also tried added a “force pulling towards the center of the circle” based on the perpendicular vector of the front tires. It doesn’t quite rotate around the circle and drifts when I stop.

https://i.gyazo.com/a36f0e2f08e0e9da134f61c768df1533.mp4

Would you like to see my code to help me find the issue?