Saturday, 26 February 2011

UDK Motorsport: More about gear plots

I stopped my experiment about manual gear boxes when I got my proof of concept working. But the curves I used were a bit poo. I want to see how to create the sound of the engine according to its RPM, but I can't do it if I don't have proper torque curves. But how can I make those curves, based on an existing engine? (Warning: lots of maths involved here)

Remember that there are two visual tools that give us information related to the engine:
  • The gear plot tells us at which speed spins the engine depending on the vehicle's speed.
  • The torque curve tells us how much torque the engine provides depending on its speed.
You get the picture? By feeding the gear plot into the torque curve, we should get a graph that will tell us how much torque the engine provides depending on the vehicle's speed: exactly what Unreal wants! But before trying to achieve that combination, a deeper understanding of the gear plot is needed.

So here's the frame we're working on:

On the x axis we've got the speed of the vehicle (in UU/s and km/h). On the y axis there's the speed of the engine, in RPM. We need to put some kind of reference curve in there that we can base ourselves on. How would the RPM behave if the engine and the wheels had the same angular speed? That's easy to find out using the following formula:
where ω is the rotational speed (in RPM), v the vehicle's speed in UU/s and r the radius of the wheels in UU (assuming they're all the same). Note that this is obviously dependant on the size of the wheels, which is why your car's speedometer is off if you put bigger wheels. Put into our graph, this formula yields the following curve:

As you can see, at very low linear speeds, the engine is hardly spinning, hardly providing any torque. Being a simple linear function, it's easy to apply multipliers that represent the gear ratios:
Sorry for the barely visible yellow line, gnuplot chose the colors for me.

Now that we have a proper, custom gear plot, we must learn to read it in order to be able to tweak it. Note that I've also added to the graph a red horizontal line representing the engine's red zone (chosen arbitrarily).

When we accelerate in first gear, the engine will go from 0 RPM (actually no, but save that for later) to the red zone. Once there, the car has reached about 50 km/h. The driver shifts to second gear. However, as the car is already in motion, the engine won't go back 0, but to whatever speed it should be on 2nd gear. We can get that value by tracing a line straight down from the point where we shift gear until we meet the curve of the next gear. If we only keep those bits of curves, we get the "real" gear shifting plot. It's now time to read this.


The more vertical the gear line is, the less time it will take to reach the maximum RPM, meaning more acceleration and less top speed.
Note that on the above curve, the 4th gear is starting at a lower RPM than the 3rd, meaning they're probably incorrectly adjusted. It's not a bad thing, but the engine might be less efficient this way.
Usually, all gear ratios are multiplied by a common factor called the final countdown drive. It's just a tool that lets you scale your entire gears settings. On the curve above, the final drive is 5, and the gear ratios are, from 1st to 5th: 4, 2.5, 1.75, 1.15, 0.8.

So now we know how to make a proper gear plot, how can we make this combination with the engine torque curve? I'll be talking about that in an upcoming post as this one is getting lengthy.