;

## Krazy Karts

Learning how to implement simple car control calculating the physics from scratch.

Implemented using: C++, Unreal Engine

A simple car simulation for learning how to implement rudimentary physics. The real time data of the user input (throttle and steering) is then used to calculate final velocity and rotation of the car.

### Forward / Reverse

##### Tweakable Constants
• Maximum Drive Force of the simulated engine.
• Drag Coefficient of the object.
• Rolling Resistance Coefficient of the object.
• Mass of the object.
##### Drive Force - The force applied to the object by the simulated engine.
• $\mathrm{Drive Force}=\mathrm{Throttle \left(Input\right)}*\mathrm{Max Driving Force}*\mathrm{Object\text{'}s Forward Vector}$

##### Air Resistance - The force applied to the object from drag in the opposite direction of the drive force.
• $\mathrm{Air Resistance}=-\left(\mathrm{Object\text{'}s Normalized Velocity \left(Direction\right)}\right)*{\mathrm{Speed}}^{2}*\mathrm{Drag Coefficient}$

##### Rolling Resistance - Force applies to the object by gravity and the friction of the object and contact surface.
• $\mathrm{Acceleration Due to Gravity}=\mathrm{Mass}*\mathrm{Gravity Force}$
• $\mathrm{Rolling Resistance}=-\left(\mathrm{Object\text{'}s Normalized Velocity \left(Direction\right)}\right)*\mathrm{Rolling Resistance Coefficient}*\mathrm{Acceleration Due to Gravity}$

##### Acceleration - The force applied to the object taking in to account the parameters and law of motion.
• $\mathrm{Acceleration}=\frac{\left(\mathrm{Drive Force}+\mathrm{Air Resistance}+\mathrm{Rolling Resistance}\right)}{\mathrm{Mass}}$

##### Final Velocity - The current velocity of the object in the current time slice.
• $Final Velocity=\mathrm{Current Velocity}+\mathrm{Acceleration}*\mathrm{Delta Time}$

### Steering

##### Tweakable Constants
• $Distance Delta=\mathrm{DotProduct}\left(\mathrm{Velocity},\mathrm{Object\text{'}s Forward Vector}\right)*\mathrm{Delta Time}$
• $\mathrm{Rotation Angle}=\left(\frac{\mathrm{Distance Delta}}{\mathrm{Minimum Turning Radius}}\right)*\mathrm{Steering \left(Input\right)}$