I love arcade racing games. Mario kart, Outrun, Forza Horizon are some series I often find myself coming back to play and enjoy over and over again. Because of that, driving mechanics are something I am very interested in. For as long as I have used a game engine, I always have tried to implement an arcade car controller. This time I want to create one that uses the wheel collider system of Unity3D.
#0 - Car controller and camera movement
In order to design a car movement that constrains the acceleration and maximum velocity in a simple fashion, I opted to apply forces on each of the motor wheels instead of adding torque. This simplifies the code a lot and still makes use of the physics engine of Unity3D.
For the camera controller, I used the Cinemachine package.
#1 - Drift and skid marks
Once the vehicle was moving as I imagined, I decided to program a "drift" button that allows the player to take more difficult curves in a fun way.
Before I continued polishing and improving the movement, I decided to include some basic effects to increase the sensation of movement and speed (such as the antenna on top of the car and the skid marks on the ground)
#2 - Volume Effectors
The basic movement of the vehicle is ready. Now it is time to build a short level around the vehicle mechanics in order to test whether my ideas for the game are fun or not. In order to make the level exploration more engaging, I want to include jumps, turbos.
To achieve that, I created a script that simulates a "volume effector" where certain forces that can be specified through the inspector are applied to the player's car.