Physics Vehicle

C#

1

12 weeks


‘Create a third-person character controller that relies on rigidbody physics to move’

Second Year Trimester 1 University Project

This project is currently in submitted but ungraded yet

Raycasting, procedural generation, physical forces

Physics

I am creating a physics simulation using Unity C#

Using the rigidbody but with my own implementation of the forces being applied to the world.

Gravity applied by accelerating all objects to the ground with -9.81m/s velocity

Drag applied using the drag equation Fd = 0.5 p u^2 cd A

p - density of air calculated by getting the characters Y axis value and mapping against table to calculate air density which changes as the vehicle gains altitude to allow for aeroplanes performance changing at heights

u - velocity taken from characters rigidbody component

cd - magic number coefficient used to approximate drag factor

A - cross sectional area calculated by generating a grid of raycasting nodes in front of the players movement vector, each node hit is counted and represents a 10cm^2 surface area. All raycast hit normals are averaged to determine if a y component of drag needs to be included to give lift to an aeroplane or downforce to a spoiler wing

Suspension Forces

Wheels

Suspension implemented via raycast nodes at each wheel position detecting the distance to the floor, and applying a spring force using the spring equation F = kx.

Extra Content

Implementation of a racecourse that times laps and displays best times for each car in the session.

Ackermann steering to apply different turning angle for each front wheel so their turn circle is aligned to reduce slippage

Sound manager for central dictatorship of sound playing.