I've been slowly progressing on my boating game over the past few weeks, it's been great that I seem to have a few people interested on youtube, despite me having no firm idea on a game design. I guess once you have water and land and boats you can use it for everything from racing to pirates / trading type games.
Physics
Physics has (allegedly) improved since my last blog post, instead of taking just one height sample at the centre of a boat I now use 3 samples in a triangle, to get an idea of the normal at the sea surface. This means that boats can now more closely match the surface instead of just up / down.
The up / down motion is now working through the physics, rather than my previous approach of running the physics on a level ocean, then applying wave height to the displayed model only. There are disadvantages and advantages to this and it is subject to change. On the plus side it should eventually interact correctly with things like land masses, but currently the impulses to push the boats to sea level cause mad jitter on beaches! Boats also can take off now if you drive them over waves over a certain speed.
Skybox
First I tried using the world environment to create a skybox in godot, but had very mixed success. It was easy to create a procedural sky but because of the PBR shaders, the boat models etc ended up having a horrible blue colour cast. I tried various methods to get rid of the cast but failed miserably.
In the end as I'm not really interested in PBR for this game I changed the world environment just to clear to a blue colour without a skybox, and I created a quick manual skybox in blender which I move around as the camera moves (needs a little tweaking). This looks good enough for my purposes and it means it doesn't get used in the PBR lighting so no colour cast (in fact I suspect it is defaulting to simpler shaders).
Moving Origin
As I was thinking of maybe having large worlds with a lot of sea to cover, I decided to have a 'moving origin' system to prevent floating point error in physics etc. It is quite easy to put in at an early stage, but more of a nightmare if you leave it till later, so I put it in early.
The third person camera is focused on a particular boat at any time (e.g. player), and if that boat moves more than a certain distance from the origin, the whole world resyncs so that the boat is now centred on the origin, and the objects around are all teleported to their offsets from the player. This seems to work fine providing it is done at the correct time in the physics.
Land
Originally I was thinking of a simple game at sea only, but then realised it would be a lot more flexible to have land too. First I experimented with a simple plane for a beach, with a static collision box underneath it for the physics. I was planning on having a few different variations of beach geography, then stitching them together.
The more I experimented the more I got dissatisfied with this approach, as it looked very inorganic, so I brainstormed for some other techniques. The difficulty was as well as looking right the approach had to work efficiently with the physics (and the moving origin).
I wondered about using Delauney triangulation with some random points to get some land masses, but having a nice c++ implementation already in my library, I couldn't quite face translating this to gdscript. Plus, how would I handle the physics? Maybe Godot handles some polygon soup, but it would probably not be pretty.
Next stop was a heightmap, but again I was worried about the efficiency of the physics and lots of special cases.
Then this morning in bed I had a brainwave. Yesterday I had been experimenting and Godot has the ability to automatically build a convex hull physics rep around a mesh. I know from previous experience convex hulls work pretty good with physics, so instead of making e.g. a beach with this technique, why not create an entire island? Maybe I could just place islands on top of each other, interpenetrating, to create more complex coastline?
It probably will look awful on the joins but given the ease of implementation this is my current winning technique. I made a quick low poly island in blender this morning, used the 'convex hull' operator in blender to ensure it was convex, UV mapped it and then did a quick texture paint in 3d paint. Whapped it in the game, added a convex hull static collider, and it's working great!
Usually in these situations I'd also do procedural texturing but gdscript is a little slow for that, when I tried it in my frogger game, so probably just some manual textures for a few island types will do the trick.
Anyway the final result is shown in the video. There might be some physics jiggle on the beach in this, I have to work on the boat physics on land, there seems to be some crazy interpenetration physics bug even in simple circumstances with a box against convex hull, maybe it is a bullet bug or some scaling or epsilon that is wrong.
Maybe you would enjoy this...
" Ziba Scott (Popcannibal) goes through simple examples of vector math and world/local space transforms to build a multi-threaded buoyancy system."
https://www.youtube.com/watch?v=OOeA0pJ8Y2s