NightRacer
Aap Vare
Introduction
NightRacer is a 3D drag racing game set in the dark streets of a modern city. It is inspired by the likes of Need For Speed Underground 2. It features a track in a dark city environment illuminated by street lights where you can drag race in a fast car with functioning driving mechanics.
GitHub repository: https://github.com/Fa1nt/NightRacer
Latest build: https://drive.google.com/file/d/14AGTP-_kUG5Kw4VPzfjaSz9xtWwu092X/view?usp=sharing
Video: https://drive.google.com/file/d/1p7mZRylnUPyslTHTJs7LmxBh9fu3MTHP/view?usp=sharing
Goals of the project
The ultimate goal of the project is to have a game with good working driving mechanics and visually appealing nighttime graphics. The mechanics would feature accelerating, braking, turning, manually shifting gears, and nitro. The game would be set in a city during the night illuminated by street and car lights and buildings in the background. The car would have to have reflections particle effects. The plan is to also have a splitscreen multiplayer feature to add a competitive element to the game.
The overall plan will be to:
- Source the necessary models and textures
- Implement the driving mechanics
- Add an UI
- Create the map
- Implement the game logic
- Implement the lighting
- Add visual effects
- Add splitscreen multiplayer
Required technologies
- Unity
Foreseen difficulties
- Driving mechanics
- Lighting
- Splitscreen
Milestone 1 (05.10)
- Sourcing the model and textures for the car (1h): 0.5h
- Implementing some basic driving mechanics (4h): 3h
- Adding some basic UI elements (1h): 0.5h
Progress
I managed to find a good looking asset for the car that is going to be used in the game from the Unity Asset Store (https://assetstore.unity.com/packages/3d/vehicles/land/low-poly-sports-car-20-144253).
The driving mechanics implemented in this milestone were accelerating, reversing, turning, and braking. In general, this did not take as much work as I expected because there are many tutorials for coding these sorts of things in Unity online. I applied WheelColliders to each of the wheels and transformed the rotation and angle of them accordingly to move the car.
Since there is no game logic implemented at this point, the only UI element I added was the speedometer. Getting the text to update was a bit of a hassle but I know now how it works and can use this to create other UI features in the future.
Milestone 2 (19.10)
- Create the physical collidable area of the map (2h)
- Add gear shifting and nitro mechanics (2h)
Progress
I created a track for the race out of some road assets I found in the Unity Store. The track may need to be extended but thanks to the modularity of the assets it will not be a big concern. The current track is fit for testing and adding the game logic.
Adding the gear shifting and nitro mechanics proved to be a bigger headache. As of right now they are implemented simply as a part of the UI and do not actually affect the driving.
Milestone 3 (02.11)
- Make gear shifting and nitro affect the performance of the vehicle (6h)
For this milestone I succeeded in implementing the gear shifting and nitro mechanics. On top of that I managed to improve the handling of the vehicle as well. I discovered that there are some values in the wheel collider component that I had not tried altering before. Increasing some of these values helped to remove the bothersome delay from the acceleration and deceleration. This also significantly increased the overall speed and acceleration of the car.
Shifting gears will now help increase the speed of the car. If the player shifts up too early then the car will not go as fast. Each gear has its own top speed. I also implemented a logarithmic function to calculate the motor torque value applied to the wheel colliders. This means that the increase of speed is no longer linear.
Milestone 4 (16.11)
- Add starting countdown, finish line, and timer (3h): 3h
- Add visually appealing UI elements (speedometer, N2O bar) (3h): 3h
- Bonus: add the second car and camera for the splitscreen (1h)
The starting countdown and timer have been added and they are functioning properly. The collider for the finish line also exists but is currently not functional. An analog speedometer made up of a background and a moving needle has been added alongside a bar for the nitro.
Milestone 5 (30.11)
- The multiplayer functionality (2nd car, splitscreen camera, 2nd player controls) (6h): 6h
Splitscreen multiplayer functionality has been added to the game and is working. Adding the splitscreen itself was surprisingly easy. For this I added a second camera to the scene and I changed the X and W values of the viewport rect in the cameras.
After that I spawned in another car to which I attached the new camera to. Then I modified the car controller script by adding a new set of controls on the keyboard for the second vehicle. An additional speedometer has also been added for the second player as well as a final scoreboard for both players when they finish the race.
Milestone 6 (14.12)
- Finish the map (add buildings, lamp posts, night sky) (4h): 4h
- Add controller support (1h): 1.5h
- Add menu and restart button (1h): 1.5h
A menu has been added to the game that allows the player to start and quit the game. It also shows all of the different controls needed to play. When one or both players finish the race, either of them can choose to restart or exit to the main menu.
The lighting has been drastically changed. The skybox is dark and intensity of the default directional light has been significantly reduced to create the nighttime atmosphere. Lamp posts have been added along the street for illumination. The headlights and the rear lights are now working on both cars the enhance visibility. There are now buildings on both sides of the street to make the map feel less deserted. There are now invisible walls surrounding the level to avoid going off course.
Controller support has been added for both players.