I do not want t use physics because car goes straight and with the full gas all the way.
But I can not find or understand car acceleration formula.
So I see it like this:
Car speed this is engine RMP / gear ratio
I have current gear and gear ratio
How can I find engine RMP increase per time unit. Witch is basically acceleration.
I am sure I should use air resistance, and Engine TorgueCurve but do not know how exactly.
If you understand basic kinematics, it’s fairly easy to approximate a car’s movement.
You’ll need to keep track of a few values:
Engine’s rpm
Engine’s gear
Car’s acceleration
Car’s velocity
Velocity is change in position over time – the rate at which your car moves. Acceleration is change in velocity over time – the rate at which your car’s speed changes. The distinction is subtle but crucial; if you don’t understand it already, I’d look up some math/physics tutorial videos until you do.
You can update these values during each frame, something like this:
Since you’re doing drag racing game you would probably want users to have options to modify their cars. If you want then to dynamically calculate the torque to RRM curve based on new engine specification after mods then you would have to physically simulate inner workings of the engine and that’s impossible with today’s calculational capacities.
All games that allow users the modify engines rely on fakery.
Just to be sure. The torque doesn’t tell you about the RPM change directly. You would have to use your current RPM and wheel torque at that RPM to calculate how much force is being put to accelerate car. Add this with forces decelerating car like friction etc. to get the new car speed (since last frame). The new RPM will be a function of new car speed (EDIT: as measured on drive wheels and not the actual car speed of course), current gear ratio and driveline efficiency. This last factor by the way is significant. It often goes as low as 70%. (EDIT: actually it only matters when calculating wheel torque compared to engine torque. When calculating RPM based on wheel speed it doesn’t matter, only gear ratio does. We only care what the rotation speeds are regardless how big of a force is causing them.)
Offtopic: Why the “full gas all the way”? In drag racing how you start is crucial and you never start with 100% throttle. That would just make wheels loose all traction and spin crazy putting energy into stripping rubber off them rather then accelerating car. If you do implement gas control then your current torque is simply maximum torque at that RPM (value from dyno result curve) times the throttle position in range: 0f - 1f.
Okay thats guys for responses I have read a lot articles about it. So i guess it should look like this:
I have current engine RMP , using dyno stand curve I can get current engine torque.
Fdrive = Tengine * xg * xd * n / Rw
Tengine - Engine Torgue
Xg - Gear ratio
Xd - Final Drive
n - drive efficiency (0.7 approximately)
Rw - wheel radius
Next step: calculate resistance
We have air resistance and wheel friction resistance.
Those forces can be calculated using current car speed.
So our car forward force will look like this
Flong = Fdrive - air resistance - friction resistance
Eventualy I can get acceleration
a = Fdrive / weight
with can be interpreted as I want to, even like engine RMP increase per time unit.
Actually if you do dyno your self or get the data from net it is likely you’ll have the wheel torque measured so you won’t have to worry about the relation to engine torque. On the other hand if you do want to fake some engine modifications then you might want to work with engine torque and convert it to wheel torque although not necessarily since it’s fakery anyway so who cares.
The part with friction is more tricky if you want to go sim style. If your tire had perfect traction then all wheel torque would go to accelerating car. However in practice how much of that torque goes to accelerating the car depends on surface of tire touching ground and friction between tire and ground. Both of does can be complex problems depending on just how sim you want to go.
Surface will depend on tire radius and width and current shape (it will change dynamically based on forces acting on it, material properties andair pressure inside) and the ground geometry beneath it - not necessarily flat.
Friction will depend on material properties of ground, what’s between ground and wheel (water, dirt) and tire material properties and those will change also based on tire temperature and air pressure.
The energy that doesn’t go to acceleration will be spent on turning your tires into smoke etc. but most importantly into excessive spinning - think bournout. This part is important because we update our RPM based on wheel speed (and not actual car speed). You can actually see this in real car when you do a burnout the speed-o-meter will show you high speed although you’re barely moving because it works based on drive wheels speed.
EDIT: There’s also suspension. Passing some torque to wheels will make suspension work and that consumes energy too but also affects weight distribution between wheels and thus traction.
All this is probably more detailed then you need and I am only theorizing here - haven’t done this stuff my self so I can’t give you any practical advice on actually implementing this. However I do know there is a lot of resources on car physics programming on the net so you should do some searching.
But I want to keep it simple.
For example I have weight in 750kg over drive wheel, with means. max acceleration can be:
750 * 9.8 = 7350 Н.
But on the first gear car get 9000+H in this case wheel will start to slip.
But instead of this I will just cut the power to 7350 Н (simulation clever driver)
I guess I will enough with simple friction resistance coefficient. Because car always go starting (no hills) always on good road.
What do you thing?
And I really appreciate your help. Regarding other formulas is I am on the right direction?