I see that kind of percentage performance parts in some games, but the way they increase performance is a bit different what it looks. For example; if I apply the engine’s stats to the both cars, the cars’ new stats will be like this:
Car A → Top Speed: 250 + 25 / Acceleration: 400 + 20 / Handling: 650 + 0
Car B → Top Speed: 500 + 50 / Acceleration: 600 + 30 / Handling: 600 + 0
As it can be seen, the engine affects more the most performant car than the other one. In racing games, it’s quite the opposite. The more the car is performant, the less the performance parts affect. How does that logic work? I want less performant cars to be affected more by performance parts and vice-versa.
In other racing games, the stats would be like this (just an example):
Car A → Top Speed: 250 + 35 / Acceleration: 400 + 25 / Handling: 650 + 0
Car B → Top Speed: 500 + 20 / Acceleration: 600 + 10 / Handling: 600 + 0
It must be related to the max. stat, which is 1000. A car can have the maximum of 1000 for each stat. The more close to the maximum, the less the performance part affects, I guess, but what’s the logic?
I don’t play enough racing games to have observed this, though assuming there is indeed a maximum the stats can reach, one way off the top of my head is to take the percentage of the difference rather than the value directly
so taking modifying top speed as an example
UseSpeed = TopSpeed + ((MaxSpeed - TopSpeed) * 0.1)
Car A UseSpeed = 250 + ((1000 - 250) * 0.1) = 250 + 75
Car B UseSpeed = 500 + ((1000 - 500) * 0.1) = 500 + 50
Most likely not the way racing games do it, assuming there is even a standard, though it does get your described behavior to some extent using your assumption.
I thought the same thing but that logic breaks the game design.
For Car A, you will always apply performance upgrades with 750 * (something). For Car B, you will always apply performance upgrades with 500 * (something). As you add parts to the both cars, Car A will pass the Car B stats eventually. That can lead players to use low stat cars instead of high ones
I would probably approach this by setting a max improvement percentage per car. So already great cars might only improve by an additional 50% with max upgrades, while bad cars might improve by 200%.
Now you can get the value to scale with by multiplying the base stat with this percentage. It might even make sense to have an max improvement percentage per stat, actually, since you might not want both engine and handling to improve by the same amount (ie 50%), depending on the stat range.
Your upgrades would work the same. Add a percentage of the calculated additional performance you can gain.
As an example, say we have a trash car with base stats 300, and 200% possible improvements = 600.
Then we have some supercar with fantastic base stats of 900 but only 33% possible improvements = 300.
With upgrades the trash car will drastically increase its performance (to 900), bringing it roughly to supercar level, but an actual supercar would still outperform it when max upgraded (1200).
Of course these relations depend on the values chosen tho. This allows for easy balance changed as well.
Also since this is the first thing that came to my mind, in reality you likely have to make the system a lot more sophisticated. It does however solve a lot of problems by allowing individual scaling per car. You could also directly calculate the max improvement percentage to the base stat (lower base value meaning more potentialy improvement, but with diminishing returns to prevent bad cars from becoming better/equal to supercars).
Let me propose a different approach, you’re trying to change the numbers that some upgrade is giving, an 10% modifier should be 10% in any situation IMO, what you need to change is how much impact this 10% represent in your game, to change the impact that something has let’s try to draw a function in the animation curve similar to a logarithmic function.
Let’s say that you have a curve like this
As you can see the increase rate is bigger in the first half than is in the second half, it will represent the percentage of max speed that we can achieve, then you have your both cars, with 500 and 250 of some status, when we evaluate these values against the function we get
This means that this upgrade had given our faster car a buff of 9 in max speed while this give our slower car a buff of 12. The point here is that as near as your status gets from the max value the lower the impact that it will have on your status, and if I understand right this is the kind of behavior that you are looking for.
Full code:
public class Example2 : MonoBehaviour
{
public AnimationCurve curve;
public float maxSpeed = 300f;
public float maxStatus = 1000;
public float carA = 500f;
public float carB = 200f;
public float upgradePercentage = .1f;
private void BeforeUpgrade()
{
Debug.Log($"Car A: {curve.Evaluate(carA/maxStatus) * maxSpeed}"); // 254
Debug.Log($"Car B: {curve.Evaluate(carB/maxStatus) * maxSpeed}"); // 167
}
private void AfterUpgrade()
{
Debug.Log($"Car A: {curve.Evaluate((carA + carA * upgradePercentage)/maxStatus) * maxSpeed}"); // 263
Debug.Log($"Car B: {curve.Evaluate((carB + carB * upgradePercentage)/maxStatus) * maxSpeed}"); // 179
}
}