hi there, I’m creating a 2d car simulator and I’m trying to get turning
to be as physically correct as possible.
The first thing I done was to create a rigid body structure for the car
body that has some properties: mass, inertia etc. The main function of
this structure is to be able to apply forces at specific points and for
it to rotate and translate itself accordingly. All this works fine.
The problem I’m having is with the wheels… I know the velocity of the
wheels and the direction they are heading, The angle between these two
vectors is commonly refered to as ‘slip angle’ I think. Currently I
split the velocity into two components - side velocity and forward
velocity (side velocity is how many m/s the tyre is moving on its side
and same with forward) and then I apply a force in the opposite
direction of the side velocity to the car, this force is proportional to
the velocity. This method seems to work, I just set a coefficient that
gets multiplied with the inverse side velocity and use this vector as a
force that I apply to the car. Can someone tell me velocity is linearly
proportional to force in this case (seems to work).
I’ve tryed doing it the proper way by storing the previous frames side
velocity and then differentiating over a a certain time (1/50th second
(50fps)) to give me the acceleration which I then plug into (F=ma).(I
say ‘proper way’ but I really dont know if it is) If the tyre pushes the
ground and the ground pushes back with an equal amount of force then why
doesn;t this work. (do I also need to take inertia into account).
p.s. I dont take weight transfer into account, in the calculations mass
is just car.mass / 4.0
Please log in or register to post a reply.
Car tires sliding sideways on pavement are subject to
friction. The simplest model
for friction force, which most games use, is for the force to be in the
opposite direction to the velocity (in this case the side velocity) and
proportional to the force with which the two surfaces are pressed
together - in this case 1/4 the car’s weight. The coefficient of
proportionality depends on whether the surfaces are currently sliding
(kinetic friction) or not (static friction), the static friction
coefficient being larger - it takes more force to get an object sliding
from a stop than to keep it sliding once it’s already moving.
So basically you’re already doing the right thing except for the
friction force being proportional to the velocity - friction is
substantially independent of velocity. (If you were talking about fluid
drag, such as from a boat motoring through the ocean, then the drag
would be proportional to velocity, at slow speeds - and velocity squared
at high speeds.)
I think I understand now, if you are going really fast and suddenly turn
your tyres 90 degrees the car won’t suddenly stop but rather slide
because friction force is not enough to overcome such a velocity.
So the magnitude of the friction force stays the same (assuming no
weight transfer) its just the direction of the force changes. And this
also means I don’t need to calculate the net force from the current and
previous velocity… I just apply friction force and its gets integrated
in on the next update. thanks, I’ll try implemnting it and see what
Thanks a lot, Its working perfect now.
I have another problem now.
basically the car body has an angular velocity as soon as I turn the
wheels when driving - this velocity will go up (or down)
The problem is that I get the velocity of the tyre using this angular
velocity and the relative offset of the tyre from the cars center of
mass. The velocity of the tyre is then used to determine the direction
of friction, therefore I apply the friction force in the opposite
direction of velocity, which , in the next frame, causes the velocity of
that tyre to be in the other direction. This is an infinite loop where
the velocity of the tyre switches between negative and positive every 2
frames, the forces of friction balance each other out but not in the
same frame. therefore the image jitters about quite noticably. Also when
I turn the wheels when the car is stationary it starts to slowly rotate
about its center and then back again. I think this is because a force is
being applied one frame, the wheels turn (between frames) and then a new
set of friction forces applied in the next frame causing an imbalanced
Is there any way I can solve this?
The friction force should be capped at the force necessary to bring any
sideways motion of the wheel to a halt. The friction force should never
cause the wheel to start sliding in the opposite direction. (This is
physically correct; it’s the way real-world friction behaves, to a very
good approximation.) This should help with the first problem and maybe
the second problem as well.
Thanks again, its working. I just calculated the amount of force
required from the current frames velocity. i.e.
F = ma
a = (vf - vi)/t
a = (0 - vi)/t
F = -vi/t * (carMass/4);
I then just check if friction force is greater than this, ifso use this