Hydro v0.2

Saturday, March 09, 2019

Hydro v0.2 is officially released!

They say the last 10% of a project takes 90% of the time, and this is no exception. There are a handful of new features which should make this quite usable now, but they're not the kind of thing that will make a big splash (pun intended). I've split the functionality into several nodes, which should add a lot of versatility and make this quite usable in a variety of situations. Here are the nodes I've added:

WaterArea

This allows you to define a limited area in which the hydrodynamic calculations take place. Without this, you've only got an infinite ocean, and the module is always checking for potential submersion in the water. Now, you can add a WaterArea to a valley in your terrain, and your HydroRigidBody will be a standard RigidBody on land, and only have the extra functionality when it hits the WaterArea.

You've also got the ability to set the density of each WaterArea independently. Freshwater and saltwater have different densities, and you could also use this for pools of lava, maple syrup, etc.

WatercraftBallast

By default, the mass of a HydroRigidBody is centered at the origin of the object. Adding additional weight at various points can improve realism in some cases. The WatercraftBallast node allows you to position a point mass at a specific location. This can be useful for cases such as:

  • Creating a keel on a sailboat
  • Simulating cargo on a ship
  • Shifting the weight of a rider


WatercraftPropulsion

This can be used to add prop or jet drives, bow thrusters, or more to your watercraft. The propulsion system will only provide thrust when its origin is underwater. You can add as many as you need to your watercraft and control them independently.

WatercraftRudder

This will dynamically generate a steerable rudder and attach it to your hull. As with the rest of the hull, only the submerged portion of the rudder will function.


There is also documentation for each of these nodes within Godot itself, along with the wiki.

I'm expecting to release one more version before this is feature-complete. Here's what is coming up:

  • Create editor gizmos.
  • Improve the method for debugging the forces.
  • Allow the actual shape of a WaterArea to automatically define the water height.
  • Add the ability to have a simple water flow such as a river affect HydroRigidBody objects.
  • Create a simplified mathematical model that allows you to optionally trade accuracy for speed. This would accommodate use-cases where you have hundreds of objects, or offer a fallback for less powerful mobile devices.


Finally, here's a video of the new WaterArea nodes in action, each block of water has a different density:





Comments4



I've got a semi-fleshed out idea for a game based on the ocean. This library looks like a likely useful tool for being the backbone of my idea. Do you have a Patreon that I could donate to as thanks for developing it?

Nice catch! If you run into any other issues, feel free to let me know here, or I also lurk on the Godot Discord server under the same name. I'd love to hear how your project turns out too!

The buoyancy problem mentioned below may be a bug in godot's core functionality so I created a bug report for it:
https://github.com/godotengine/godot/issues/37048

Hi. I have some problems with the water density and/or mass of the objects. If I set the water density to 1000 and create a cube of 1*1*1m with a mass of 1000 (or 2*2*2m cube with a mass of 8000), they will float about half. But if I change the water density to 500 they will be in the edge of sinking (what I expected to happen with a density of 1000). It's not a problem to set the density to 500 to work around this, but am I missing something?