Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to make car performance customization logic?

Discussion in 'Game Design' started by Paulx774, Oct 14, 2021.

  1. Paulx774

    Paulx774

    Joined:
    Mar 18, 2021
    Posts:
    103
    I'll get in the subject directly. It's better explain this with an example. Let's say there are 2 cars in my game and their stats are like this:

    Car A -> Top Speed: 250 / Acceleration: 400 / Handling: 650
    Car B -> Top Speed: 500 / Acceleration: 600 / Handling: 600

    I want to add a customization part whose stats are like this:

    Level 1 Engine -> Top Speed: 10% / Acceleration: 5% / Handling: 0%

    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 should be related to the max. stat, which is 1000. A car can have the maximum of 1000 for each stat, but what's the logic?

    If I use the difference between the current stat and the maximum (1000) then the less performant cars will have advantages.

    (1000 - Current) * Percentage

    For example; for Car A's top speed, you will always apply performance upgrades with 750 * something.

    (1000 - 250) * Percentage

    For Car B's top speed , you will always apply performance upgrades with 500 * something.

    (1000 - 500) * Percentage

    As you add parts to the both cars, Car A's stats will pass the Car B's stats eventually. That can lead players to use low stat cars instead of high ones
     
    Last edited: Oct 14, 2021
  2. Steve_Stevens

    Steve_Stevens

    Joined:
    May 3, 2016
    Posts:
    35
    That’s easy. Each part of the car is a class. Engine, transmission, differentials, wheel/tires. Each class has its data in a scriptable object.

    you can create different engine configurations in the scriptable objects. Have different options in there as well.

    You’d have say a 200hp 4 cylinder that could be turboed. The turbo option is selected and you recalculate your horsepower.

    You could have a v8 with different cams. Each cam has its own torque curve assigned to it, you just change the torque curve of your engine class to the chosen torque curve.

    you can do this with brakes, tires, rims, rear ends, etc…


    when you spawn the car, you instantiate a copy of the scriptable object for each class.

    In your garage, the menu reads the options from the scriptable object and allows you to choose them. Then you apply that value to the value of the class.

    Engine class could have an option for compression ratio that is used to calculate horsepower. When you upgrade from your choice, you change the value of compression ratio.
     
  3. Paulx774

    Paulx774

    Joined:
    Mar 18, 2021
    Posts:
    103
    My game is an arcade racing game. I do the acceleration and the top speed things linearly. The cars' acceleration is always fixed depending on their acceleration stats. The thing is performance customization increases those stats, which increases the performance.

    One way I can think of is limiting the cars' stats, but since I have 50+ cars in my game, it takes unnecessarily long. If I do that, I need to experience every car in the game to balance the game