Part 2: Buoyancy and Water Dynamics
Eureka!
The buoyant force is what prevents a floating object from sinking as described by Archimedes long before the age of computer simulations. Time has come to add it to Pirate Sea Jam.
Buoyant Force
The strength of the upthrust is directly proportional to the volume of the fluid that would otherwise occupy the space taken by the object. So to make something apparently float we need to calculate volume of the displaced liquid and push the object in the opposite direction of gravity.
Calculating the volume below the waterline of something like the hull of a ship and accurately applying the resulting buoyant force is not straight forward. A common simplification is to use several geometric primitives like cubes or spheres that acts as virtual pontoons and attach them around the edge of a main shape, which represents the ship. The buoyant forces of each pontoon act in conjunction on the main shape and ideally make it bob like a boat gently on the sea.
Drag force
When simulating buoyancy it's easy to end up with something that looks like an object attached to an invisible spring oscillating up and down around the water surface. To mitigate that problem we need to introduce a drag force, which is a damping force for objects that move through fluids. The drag force is proportional to the square of the velocity. In other words when the speed is doubled the drag force is increased fourfold. The size and the shape of an object also affect the damping.
Usually you have to fine tune the magnitude of the buoyant and drag forces to make your craft float somewhat realistically, but once you have a configuration that works, pump your fist in the air and exclaim "Eureka!"
Next up
Next up is to dress the wire frame in a nice 3D model.
Ship ahoy!
Get Pirate Sea Jam
Pirate Sea Jam
Jam-sized pirate game prototype in the making. Written in Rust and Bevy. Made with ❤️
More posts
- Part 10: Sailing Physics SimulationMay 31, 2024
- Part 9: Total rewriteFeb 07, 2024
- Part 8: Creating an Infinite OceanNov 20, 2023
- Part 7: Dynamic Orbiting CameraNov 13, 2023
- Part 6: Adjusting for Mobile DevicesNov 02, 2023
- Part 5: Shooting Cannon BallsOct 15, 2023
- Part 4: Player control and Game FeelOct 04, 2023
- Part 3: Adding Low Poly ModelsSep 02, 2023
- Part 1: Creating Ocean WavesAug 22, 2023
Leave a comment
Log in with itch.io to leave a comment.