Physics Engine
A downloadable game for Windows
Throughout my Game Physics course, I developed my own physics engine from scratch in C# using Unity. None of the built in Unity physics components are used. I developed my own version of a rigidbody that declares and modifies acceleration and velocity. Different types of forces can be added and other features such as force generators that continuously apply forces to objects. I have implemented Oct-Tree spatial partitioning and, while I added a binary space partitioning solution, I only had time to implement it for spheres so it has been removed from the final project. I implemented spring components as well. My final project was implementing friction and resting contacts so objects lose momentum when colliding with surfaces that have a coefficient of friction lower than 1.
There are several controls to the project to showcase the features.
WASD - movement
Space - pause physics objects
T - switch collision methods (between naive collision and oct-tree spatial partitioning)
Enter - Hold to increase power and release to fire a projectile
F - switch projectile types, all but the standard cube and sphere disappear after a period of time
Left and Right Arrows - Increase/Decrease gravity in x axis
Up and Down Arrows - Increase/Decrease gravity in y axis
Page Up and Page Down - Increase/Decrease gravity in z axis
It is worth mentioning that the benefits of spatial partitioning are most obvious when there are a large amount of objects in the scene. The best way to do this is press Enter until the frame rate starts to drop, then press T to switch to Oct-Tree spatial partitioning to see the difference in performance.
As far as the UI goes, FPS is updated every half second, "Type" refers to the collision method being used, and "Checks" refers to the number of collision checks since the last time the collision method was changed, not the number of collision checks per second.
Leave a comment
Log in with itch.io to leave a comment.