Car acceleration/deceleration functions

Started by
3 comments, last by Erik_N 23 years, 10 months ago
Whats a good function to model the acceleration of the car, where speed_of_car = f(t); where t is time un milliseconds. Or just a good algorithm to do it. I might implement gears later but for now automatic is cool. Also how can I correctly model the decelaration of the car when it hits something or the gas pedal is lifted. Thanks for any help Erik - ErikNilson@yahoo.com
Advertisement
let''s say you have function f(t) no matter what the function is...

the velocity of the car would be the derivative of your function... then the acceleration would be the derivative of your velocity function...

e.g.

let''s say you have a function like f(t)=t^2+5t+7

say that you threw a rock or something in the air... that''s the parth of the rock.. in order to find the acceleration you would do

velocity=v(t)=f''(t)=2t+5
acceleration=a(t)=v''(t)=2

get the idea? you would use something similar for your car.. I''ve never done a car game and I''m interested to find out how it''s done as well.. hope this helps a bit..

..-=ViKtOr=-..
try reading these articles, they are really cool if you are making a racing game:

http://members.home.net/rck/phor/

-Lev
Thanks for the responces. That physics book is amazing. Thanks a million. My physics will now kick ass, there''s just so much to do. Not only is acceleration covered, but traction,cornering,wind resistance, and more. It is done by taking into account the time,acceleration,velocity just as Gladiator suspected.

BTW
the acceleration formula given in this book is
time = sqrt(distance * 16 * a(# of g''s) )
but I''m sure it''s a typo for
time = sqrt(distance / (16 * a) )
because this is what works out.
I switched it up to
distance(speed per frame) = time^2 * 16 * a
So say a stock car with 1/2 g''s of acceleration would cover 8 feet in 1 second,32 feet in 2, and a quarter mile in 13.

P.S. Do you have anything more like this about high level game making algorithms? Also if you need help with something don''t hesitate to ask, I definately owe you one.


Hey. Here''s the actual accepted physics acceleration/deceleration equations. They neglect air resistance, but just factor in a random number scaled to the velocity and you should be fine:

final velocity = original velocity + acceleration * time

displacement = .5 * (original velocity + final velocity) * time

displacement = original velocity * time + .5 * acceleration * time^2 <---- time squared

final velocity^2 = original velocity^2 + 2 * acceleration * displacement

Displacement is the distance from the starting point to the final position.

These actually work quite well in free-fall applications. By the way, if you''re dealing with two or even three dimensions, calculate them separately - calculate x''s variables and then calculate y''s variables and then calculate z''s variables.

Hope you find this useful.
-Ender Wiggin

This topic is closed to new replies.

Advertisement