top of page

Speed : A racing game by yours truly.

Get ready for the ultimate adrenaline rush in "Speed," the most thrilling street racing game to hit the gaming world! Immerse yourself in the heart-pounding world of underground street racing, where skill, strategy, and sheer speed determine who rules the asphalt.



Key Features:


Customize Your Ride: Take control of the streets by customizing your dream car. From sleek sports cars to powerful muscle machines, choose from an extensive range of vehicles and fine-tune them to perfection. Show off your unique style with a variety of customizable options, including paint jobs, decals, and performance upgrades.





Urban Playground: Race through dynamic and immersive urban environments, each with its own set of challenges. Navigate sharp turns, dodge traffic, and unleash your nitrous boost strategically to leave your rivals in the dust. Explore multiple cityscapes with stunning graphics that bring the streets to life.


Thrilling Game Modes: Experience a variety of heart-pounding game modes that cater to every type of racer. Engage in intense one-on-one duels, participate in high-stakes tournaments, or conquer the open world in an epic free-roam mode. Every race is a chance to prove your skills and dominate the competition.




The Process

Now that you are familiar with the game, here's some insight into how it was made.


The Cars

The cars are built up of several classes, I wanted a semi-realistic feel that leans more into simulation than arcade, there is a Vehicle class that serves as the central hub of all the other components that the vehicle is made up of as you can see in the screenshot below.


The heavy lifters of the car physics include the Vehicle Engine class which simulates and engine using a torque curve, the Vehicle Input class has a throttle, brake, steering and handbrake input, the important one here is the throttle, the engine will rev from idle to max rpm depending on how hard and for how long the throttle is pressed and the transmission which handles the gear ratios and gear changes.


Here is a code snippet for how the Engine RPM is calculated :



float gearRatio = input.IsInReverse ? transmission.powerData.reverseGearRatio : transmission.powerData.gearRatios[transmission.CurrentGear];

        totalPower = transmission.powerData.torqueCurve.Evaluate(engineRPM) * (gearRatio);

        totalPower *= input.RawThrottle;

        if (input.Brake > 0 && Mathf.Floor(transmission.DrivetrainRPM) > 0)

            totalPower *= input.Throttle;

        float velocity = 0;

        if (transmission.IsChangingGear)

        {

            totalPower *= 0;

        }

        totalPower *= 2.5F;

        //REV_LIMITER

        if (engineRPM >= transmission.powerData.maxRPM)

            engineRPM -= 100;

        engineRPM = Mathf.SmoothDamp(engineRPM, transmission.powerData.idleRPM + (Mathf.Abs(transmission.DrivetrainRPM)  3.6f  gearRatio), ref velocity, engineResponseTime);

You may have noticed while the transmission is changing gear the power is totally cut off, this is how I simulated the "clutch" by totally cutting of power from the wheels as if the driver had floored the clutch to make a gear change. Perhaps later I could replace this with an actual clutch component or approximation in the Transmission class.


The Transmission

The transmission class takes in a Vehicle Transmission and power data scriptable object which is just another way of storing data in Unity, I used a scriptable object to store important information that dictates how the vehicle transfers power to the wheels.


Below is what that whole class looks like:

A torque curve is used to define where the power is on the revs. On the graph f(x), x is the Engine RPM and f(x) is the power output.

There are other variables that deal with gear changes more than power output calculations.


How much power the transmission gives the wheels depends on the gear ratios, this array

public float[] gearRatios;

represents the decimal gear ratio on each gear. This way I could use actual gear ratios from various cars such as the Toyota GR Corolla (...which I did for the hatchback vehicle).


Wheels

Avid users of the Unity Game Engine will come to understand that the built-in wheel colliders are a nightmare to work with. I've made a work around by manually adjust Wheel friction values depending on the situation. Each wheel is represented by the Wheel class, the wheel object also has a WheelFX component but we'll get into that later.


How I made the wheel colliders more bearable is by adjusting the Wheel Friction Curve of the wheel collider in real time. A wheel collider in Unity consists of many variables but the important ones are the Sideways and Forward friction values these are the ones the make or break your car controller.


The wheel is given more or less grip depending on the speed, this is where the "arcade feeling" comes into play, at idle the vehicle is give such low grip that flooring the throttle will spin the wheels (just like in real life). As the vehicle picks up speed from a burnout the wheel gets more and more grip.

Of course if you start slow and pick up more speed from the the vehicle will behave accordingly.


I'll dive in a little deeper into the vehicle physics in a future blog, if you've made it this far, thank you so much for reading!

30 views0 comments

Commentaires


bottom of page