"The Weather Gage" - Sailing Naval Simulation

Thanks @paul_meynckens , I will think about adding the trails again. I had them in one of the first versions but it looked too “arcade” to me, but I understand it can make it difficult to follow some action. I’ll think if making the effect subtle can achieve a good balance. Perhaps simulating the blur of the fast-moving cannonball …

Still making progress in the project (slow but constant).
After updating to Unity 2019.2 I started testing the new Terrain-Tools functionality for generating the coast. Mainly the support for generating neighbor tiles is useful for this project since there is a lot of coast to generate.
Before, I used information about the coastline to generate the coast meshes procedurally, but I had issues generating the terrain far from the coast and also deleting modern elements in the map (e.g modern industrial ports, bridges, …). Now with the the normal unity terrain tools I use modern height maps of the coast, but can eliminate modern built elevations by modifying the imported elevations.
Here a small test of the entrance to port Mahon, Minorca (still need to populate it with some trees and buildings)

3 Likes

Finally found time to update the weather asset (Unistorm) to the latest version and now some nice clouds are back in the game :slight_smile: (some weather features were broken after the latest Unity update). I was getting a bit bored of seeing perfectly clear skies the whole time :smile:

1 Like

After some comments about the robot crew in all the ships (i.e. placeholders) and not finding already available character models proper for my project, I’ve decided to give it a try modeling my own characters.
To save some work modelling I took the head and hands of an existing human base mesh and modelled the uniform on top of that. Since I have limited experience modelling humans, I think there is still a lot to learn and improve (geometry, rigging and textures), but it’s good to start replacing the robots :slight_smile:
The first model is an officer, because the model will be used the least, so the more common and visible models can wait until I have more practice. What do you think about this first attempt?
The hair needs of course to be added :stuck_out_tongue:

Now working also on a model for the normal seamen (manning the steering wheel). Also added hair to the officer’s model. I recycle the head & hands and will change only the uniform for the different crew roles (seamen, officers, marines, …)

1 Like

After creating new models for seamen, officers and marines, I can post a new video showing these improvements. What I like the most are the marines at the mast’s tops shooting to the seaman below with their muskets :). For the marines I have created the long animation for loading the smoothbore muskets from scratch, could not find anything similar :smile:
Here I can also finally show the 9 pdr frigate in action.

3 Likes

I like this kind of games. Great work, looks amazing. :wink:

1 Like

It’s time to focus again in gameplay aspects, such as the AI of the NPC ships. The most difficult task for the AI development in this simulation is the navigation of the ships. The navigation AI of the ships has to consider direction of the wind, turning radius and not hitting land or other obstacles. It also has 2 kind of tasks: sail to certain targets and manouver the ship to point the broadside(s) to shoot on targets.
Unity has already navigation AI, but the behaviour of the agents or pathfinding functions doesn’t fit the constraints for these ships (e.g. direction of the wind, turning radius) Therefore the navigation AI of the ships requires the development of some specific functions which are partially supported by Unity’s navmesh.

Below you can see an example of a ship finding the course to point its broadside to the target. The navigation AI uses a search tree (lines flowing from the selected ship) to evaluate how good are the posible positions/orientations (i.e. nodes). The direction of the wind and the angle to the target are used to calculate the value of each node and choose the best one and therefore the necesary steering action (green nodes and lines mean high value, red means low value)
The nodes are limited to the valid positions allowed by the navmesh (in the example below, an obstacle is in front of the ship, avoiding a straight path)

2 Likes

Hi Aidedecamp

Firstly can I say, this looks an amazing project and I’m really impressed with all you have done with it so far. I’m especially impressed as I’ve had a very similar project in mind for a few years and you have got a lot further with it than I ever did.
Much the same as yourself, inspired by Patrick O’Brian and similar writers (and heavily influenced by Silent Hunter 3!), I wanted to create an Age of Sail simulator. I was less interested in fighting (although I would eventually have reached that point I think) and more sailing and control of the whole ship. I spent about a year with a lot of experimenting on many individual aspects: Accurate bouyancy, I tried a few ocean assets (Ceto, SUIMONO, UWS, Lux Water), TENKOKU for weather (I really wanted celestial navigation with a sextant as part of the game so accurate lunar cycles was a must), real time terrain generation from height maps, cloth physics for sails and more. I never managed to pull all those disparate ideas into a single “whole” due to life events but all the code still sits on my hard drive, occasionally reminding me of what could have been.

After not touching it for about 3 years, I now have some spare time and thought I’d try and put that to use by resurrecting the old corpse and trying again, but before I started I did a quick search and came across your wonderful project! And my eyes lit up seeing you’d already done so many of the things I envisioned.
I’d still like to proceed with mine as like yours it’s a pet project of what I want to be able to use and I think we are hitting it at slightly different angles (mine is a hardcore sailing simulation with every sail and hull force being calculated - even so far as wind shadowing on the sails and the player controlling each mast and sheet) but if you wouldn’t mind I would love to ask you about certain aspects of your project to save me reinventing the wheel again.

Even if not (and I fully appreciate that you might prefer to keep your ideas to yourself) I have to congratulate you in getting so far with your dream; it really looks marvellous.

2 Likes

Hi VictoryWorks, thanks for your nice worlds about the simulation :slight_smile: it’s also very nice to know that some people could be so interested in such a sailing simulation, to consider about developing it too.
Yes, you can for sure ask about topics which are interesting for your project and we can share some ideas to improve both projects. I would be interested also to see what you have already achieved (thread?), when you resurrect your code.

I’ve also invested a some time in the sailing simulation (very often programming with the book “Seamanship in the age of sail” from John Harland open :smile:, if you know this reference book), but I see I didn’t show too much about it yet. About couple of topics that you mentioned:

  • Sails are simulated indepently using a physical model (like an airfoil) to calculate both drag and lift forces of each sail to apply forces on the proper position on the masts or rigging. As you mention, wind shadowing is also simulated, considering how each sails can reduce the wind from another one. This is done with raycasts from the cloth vertices in the relative wind direction, which can hit the collider of other sails to caculate the efficiency depending on the distance (see picture below with debugging representation)
    The result is good enough to achieve a speed profile depending of the point of sail, which looks similar enough to real world results (e.g. faster with a quartering wind than running before the wind or close hauled)
    Sails can be controlled individually manually (set or furled, angle), but in the videos I let the ship’s master do the job (algorithm which controls the proper angle according to old trim rules … even real captains had a master supporting them ;))

6257381--690101--WindShadowing.JPG

  • Hull forces are calculated with a simplified model, to reduce the CPU load. The buoyancy is calculated with a simpler mesh than the real hull, which is modelled independently to match the rendered meshes (sea example of HMS Surprise below, with masts armature). The buoyancy calculation queries the height of the sea (considering waves) at the vertices and calculates the submerged volume of the simple mesh. The result is a buoyancy force & center of buoyancy. The simulation is good enough, that the weight (according to real data for the ships) and the buoyancy force reach a balance at a depth very close to the theoretical waterline (according to plans) :).
    Drag forces for all 3 axes are simulated with different drag factors and the resistance increase considers the “hull speed” of the ships.

6257381--690104--BuoyancyMesh.JPG

2 Likes

I was curious about the transfer of control from first person to control of the ship. I’m figuring the wind controls the acceleration and separate keys control turning.

It’s possible to control the ship and first person at the same time in first person view. First person movement is controlled with the arrow keys. The ship is controlled with the WASD keys + other keys for specific actions (e.g. anchor, shoot cannons). A or D for steering, W for increasing sail and S for reducing sail. The player controls the acceleration only indirectly, as you correctly assume, with the ammount of sail or angle to the wind but other factors such as wind speed also influence the acceleration/ speed of the ship.

I decided to make possible controlling the first person view and the ship at the same time when in first person view (i.e. not necessary to change to “ship view” to control the ship), to allow any “hardcore” player to stay the whole time in first person view for realism (in the real world no captain would never have the option to see the ship from outside).

2 Likes

Cool that sounds like a reasonable way to provide control versatility.

Lately the focus of the project has been map creation and world simulation infrastracture.
Now the import of DEM data is a bit automatized to import heightmap files representing 1 degree x 1 degree. These nig heightmaps are splitted to into several terrain tiles and organized automatically in groups which can be loaded and unloaded as the player sails. In the same process the map of the coast is generated for the map representation.
The automation makes this work much faster and right now the terrain map is a region aproximately 500 km x 500 km of the northwestern Mediterranean :slight_smile:
To handle this bigger map, I had to separate the map representation and the terrain handling, so only some terrain tiles can be loaded, but the player can see the complete available map for navigation (map view). Map lines and terrain were linked before together, so the viewable map covered only the loaded terrain tiles. To change this some reprogramming was necessary.
The time saved by the automation of terrain import is now better invested at filling this map with ports which can be visitied and which give the NPC ships a reason to travel from port to port. Two examples below:

A frigate approaching the port of Barcelona, Spain (including lighthouse)

A xebec (new ship model) close to the french port of Toulon and 2 french frigates leaving it to engage the player

3 Likes

Thanks for sharing your project notes. I’ve enjoyed following your progress. I like your emphasis on authenticity. I’m a fan of O’Brian , Harland 's seamanship and I do some sailing IRL too. I’m exploring Unity and game programming in general. I am familiar with C/C++ .

I take it that you are referring to “automation” using the new Unity terrain tools you mentioned previously?

This sounds great. Modeling indivduals sails and ship physics is interesting to me. I assume this uses a Unity physic pacakage? Is there anywhere I can learn more about how to do this? I think just sailing a square-rig with control over individual sails, helm etc under different weather would be a sim for me.

I also like that you include a first person view . I like that in a sim/game It seems closer to the action , exciting, and immersive.

1 Like

Hi, the game seems great and physics looks realistic. I am interested in wind forces calculation. I suppose you used Bernoulli equation to calculate lift & drag forces on sails. How did you calculate lift and drag coefficients for the formula for square and triangle sails? I’ve tried to find some tabular data to get lift/drag coefficient, knowing apparent wind direction, but that’s not easy. I haven’t found any source of tabular data. Finally, I managed to build some formula to get coefficient by angle, making interpolation of some plot in Excel.

1 Like

Hi GlennCook, thanks for your interest :), specially if you also like O’Brian and sailing, this gives me the impression I could be on a good path. What kind of sailing do you do? Also tallships? I already sailed with a schonner, a brig and a full-rigged ship but I would also really like to have some feedback from other people with sailing experience

That’s an interesting question. After thinking about it I realized that the script for importing the height data and generating terrain and placing it in the world is using mostly already existing functions. However the new terrain tools helped me in the first exploratory phase, when I was finding out, what I wanted to achieve. At the beginning I used only used the coast lines to generade coast profiles procedurally as a mesh, but I was not yet happy with the result for the interior land in the background. The new terrain tools convinced me to give the terrain component a try. After some experiments I liked the approach more and I knew what I wanted to automate.

Unity has physics for rigidbodies, but not really somethin usefull for wind force simulations. There are functions for cloth simulation and wind or trees, but I find it only useful for the visual part of the simulation. For the sail action on the ship’s rigidbody I programmed the drag/lift force calculation and apply the resulting force(s) on the rigidbody representing the ship’s hull. See below for more details.

Hi vlBot, very good suposition ;), the sail force calculation uses exactly Bernoulli equation. Moreover the hull and rudder force calculations use the same equation but applying water’s density and different drag/lift factors.
For the coefficients for drag and lift I started with an ideal flat plate model (sine and cosine formulas), which works fine for a square rigger running before the wind, but achieves poor performance for other points of sailing. Since modern sailing theory compares the sail to an airfoil, I added an additional “airfoil factor” for angles of relative wind below 25 degree for the lift coefficient, inspired on NACA airfoil diagrams for lift coefficient vs angle of attack. In this way the lift is plausible even if it is probably not perfect. And when I test the different points of sail and compare the results with modern polar diagrams for square riggers (speed vs wind angle) the result feels realistic.

Thanks for the reply. I sail fore-aft dinghies and sloops to 32. Some club racing. No fully rigged square-sails, but only as a tourist. For me, the simulation of a full sail square-rig is chance to experiment with something Im unlikely to IRL. As you are aware, sailing and flying share physics and many of the same sensations. Some are difficult to capture in a sim. When sailing, I feel the wind on my cheek, see the string of the sails, and feel the cumulative forces throbbing through the tiller. I think flyers call it “flying by seat of your pants”. But it still amazing to me how far sims have come. Have you tried the “Painted Ocean”? its reminds me of your project. Theres also “sail simulator 5” it an old sim but don’t let that fool you- relatively unknown but it’s a pure sailing simulation ie no game element. It does however get the physics right for me at least for the boats Im familiar with.
Thanks for the Unity/physics explanations. Seems to me there is little good hard data to base performance characterics of historic square rig ships on. Individual ships undoubtably differed as well. It seems model ship performance will mostly based on contemporaneous descriptions and then tweaked until the model feels right.

Do you plan to include the american privateer Prince de Neufchatel? I know this thing is from the war of 1812, but I think it’s one of the most beautiful ships ever built.

1 Like

Ahoy there, the project looks really cool. Especially, I liked the simulation-like slow pace of the ships.

Looking to your videos I have seen that you have made holes in your sail cloths. I am also trying to have holes on unity cloths right now. Did you use stencil or made that part of the cloth just transparent from source mesh? How did you achieve those holes on the sail cloth?