- cross-posted to:
- [email protected]
- cross-posted to:
- [email protected]
I’m still figuring out the details but I have a working prototype and it uses (somewhat) accurate sail physics.
This looks great! I’m also working on a sailing game in Godot. I’m not trying to one-up you, but you may appreciate my input since I went through the same.
The code looks really minimal which is a great benefit! Mine started out like that but became more complex and full of abstractions here and there to support more features and realism as time went on. In doing so, I think the simple code is really a strength you should try to preserve.
One abstraction that I do think would make sense to add is the concept of an aerofoil as a separate node. You can model a sail as an aerofoil that can exert a force on the ship based on its own position. The positional part is important, since the mainsail can rotate around the mast, meaning that the position where the force is exerted is different all the time. Modeling it as a separate node would enable you to add multiple sails without effort as far as physics are concerned.
You can take it a step further and model the rudder as a hydrofoil. Since they work the same as aerofoils with the exception of a different density constant (water vs air), they are both actually just instances of some foil class. In my game all sails, rudders and most keels are just foil objects. They check their own vertical position and use the density of water or air based on whether they are above or below the water. It saves a lot of duplicate code in the end and allows for easy modeling of your ship object.
Side note: using RigidBody3D::apply_force() with a second argument (position) makes it easy to add the force exactly where it is supposed to be exerted. You don’t need to compute the torque yourself as the physics engine will do that.
A note on keels: during my experimentation with sailboat design (in the game), I learned that the keel/centerboard is actually really important not just for “going straight” but also “going fast”. The reason for this may be quite surprising: a keel does more that just prevent lateral movement. Since it’s a hydrofoil, it interacts with the water and creates its own lift and drag. The lift component of the keel is just as important as that of the sails for building up speed. If you make the centerboard retractable you will be able to see this difference for yourself in your simulation. So I definitely recommend adding a keel to your game and checking out the results.
All in all I’d like to say thanks for sharing! I will be following your project.
My kingdom for a good sailing game. I used to love Pirates! when I was young, for the sailing dynamics.
I played some great 2d top down web sailing sims years ago also, which set me up to actually sail.
I’ll gladly follow your updates. Good luck! Very exciting
Thanks for the support!
That sounds awesome! How many sails does the user need to manage? Is there a way for them to read the water?
Currently I only have one sail but I am planning on adding a jib and a spinnaker (possibly as upgrades the player can get throughout the game).
The prevailing swell of the waves is based on the current wind direction but that information is already conveyed by the flag. I’m assuming that’s what you mean by “reading the water”.
One sail is good. Having to sort a jib and a main is a lot to manage.
Also, will you incorporate hiking and keeping the boat flat? Including a mechanic where the player can fall out of the boat would be fun.
Reading the water is understanding where there are gusts ahead based on ripples or dark spots on the water’s surface:
Since I’m not planning on making it super realistic, I was thinking of adding a jib and spinnaker as potential upgrades to increase the speed of the boat at certain angles. The extra sails would move on their own based on the angles and wind speed.
With regards to hiking and falling out of the boat, I’m leaning more towards a disembodied camera instead of a first-person character so probably not.
I’m not sure if I’ll add reading the water as a thing but I’ll keep it in mind!
That sounds great! I’m looking forward to seeing it.
You should make it so you are sailing on a KitKat Bar on an ocean of cocoa.