Motivation
A while back, I posted this article about a showcase that features medium dynamics (aerodynamics and hydrodynamics) and an infinite sea. At the time, I knew that there is a much cleaner way to implement the physics. Therefore, I decided to build another showcase.
Project Setup
I chose to work with rojo, roblox-ts and a roblox-ts port of knit. roblox-ts is a TypeScript to Luau compiler. I tried this setup before and I found it easier to write good code with TypeScript. Knit is a game framework for Roblox that has some useful features like a βComponentβ which allows developers to bind custom component classes to in-game objects based on tags provided by the CollectionService.
Aerodynamics
The aerodynamic force is calculated with the dynamic pressure from every axis. It should be noted that the following figure is derived from dynamic pressure.
This formula only works for Parts in a compressible medium like air.
Figure 1.
, where
- y is the ratio of specific heats
- d is the density
- v is the velocity magnitude
- p0 is the static pressure
- A is the area vector of every axis
Showcase
I made a demo place here. It showcases a rocket that has a low tensile strength and an airplane that drops into the void.
Figure 2.
In the image above, you can see some debugging visuals. This is what they are:
- White or red line: A raycast (used for detecting if the airflow is obstructed)
- Yellow: Buoyancy vector
- Blue: Medium force vector
Source Code
Here is the GitHub repository that contains the source code and demo place: https://github.com/cassis163/rbx-physics.