Physics Vehicle

C#

1

WIP


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

Second Year Trimester 1 University Project

This project is currently in progress

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

Friction, suspension both need implementing

Vehicle design

Vehicles

Multiple vehicle types will be implemented to demonstrate how the physics implementation affects different vehicles as they travel across various surfaces.

Implementation of a formula 1 car, offroad vehicle, and plane are planned.