Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Games "The Weather Gage" - Sailing Naval Simulation

Discussion in 'Projects In Progress' started by Aidedecamp, Mar 10, 2018.

  1. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    "The Weather Gage" is a single player naval simulation set during the French Revolutionary Wars & Napoleonic Wars. The player follows a career as navy officer and commands a single sailing warship to capture or destroy warships and merchants of enemy countries. The simulation is based on the historic events between 1793 & 1815 and has a great focus on historical authenticity & single ship actions (frigates or smaller ships). It draws inspiration from naval history (characters such as Thomas Cochrane), fiction (Aubrey Maturin novels, "Hornblower" or "Master & Commander") and personal experience on cruises in sailing tall ships.

    Weathergage_221003 Screenshot 2022.10.04 - 00.21.26.26.png

    Weathergage_221003 Screenshot 2022.10.04 - 00.28.53.26.png

    Weathergage_221003 Screenshot 2022.10.04 - 00.41.13.09.png

    Weathergage_221003 Screenshot 2022.10.04 - 00.56.16.61.png



    What is already implemented:
    • Ship to ship combat with cannons or carronades using solid shot, grape shot & canister shot. Damage to the hull, sails, crew or rudder
    • Crew combat from ship to ship with small firearms like muskets and pistols and boarding actions with edged weapons
    • Physical based simulation of the forces on the hull (volume calculation, drag) and the wind force on the sails (the direction of the ships realtive to the wind has a big influence on the speed)
    • AI controlled ships consider relationship to other ships, own crew morale, terrain elements & wind direction to decide their behavior. Perception from NPC ships is modelled to consider light (day/night), weather (e.g. fog), false flags or size of ships to be detected
    • Imported terrain information to model coastlines. The player can travel long distances to explore the already imported coastlines
    • Simulation of the routes of other vessels (allies, neutrals or enemies) from port to port. This allows the generation of random encounters
    • Navigation & surrounding situation on the map view

    The intention of this thread is getting comments & feedback from you, get some suggestions for further development (e.g. sources of models & other resources that I can use) & if requested, provide to you also some information how some effects & functions are implemented. This is a personal project (programming & creation of models) so development is slow but continuous.
     
    Last edited: May 26, 2023
  2. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Hi Aidedecamp,

    This looks fascinating from the screenshots. The sea looks very realistic to my eyes. Do you have any video(s) to give an idea of how this plays?

    What sort of performance (FPS) are you aiming for and how big can the battles get (number of vessels / cannons / projectiles) whilst maintaining that level of performance?

    I presume you are targeting PC / console platforms - as opposed to mobile? Do you have any plans for network linked game play or is this strictly single player vs AI?
     
  3. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    Thanks, Dough_B :)
    Well, it's funny, the sea itself is an asset from the Asset Store called Ceto (unfortunately discontinued). I also use UniStorm for the weather & day/night cycle. But all the models on the pictures (except the Unity Robot Kyle, as a placeholder for crew members) are own creation.

    I'll post video(s) to show gameplay, I'll have to prepare it (I have right now only videos with old visuals, old sea).

    My target is to keep the fps overall above 50 fps, allowing sometimes spikes down to 30 fps. The focus is for small actions (mostly frigate to frigate of small squadrons), but with a higher level of detail. Right now the biggest ship (a brig) has 18 cannons, 54 animated NPCs on deck (see attached picture to see how the deck looks like)
    I limit right now the encounters to 4 ships at the same time, to stay above 30 fps on my PC. The CPU load is right now the limitation (but my CPU is already 4 years old, a newer version shall allow me some more ships in the future :))
    However the biggest factor that increases the load right now (more than number of vessels or cannons) is the number/complexity of sails, as the sail's visuals are Unity's Cloth components. The load can be up to 40% in a battle with several big ships. Therefore I'm considering to switch to sails simulated with blendshapes, at least for some cases.

    Yes, the target is PC and I work only on the single player. I've seen several good looking developments of sailing warfare as multiplayer (e.g. Naval Action). But I miss a good single player simulation, where the player can have a career/campaign mode, such as the career mode in Silent Hunter 3 (which I can still play today at the pace that I want).
     

    Attached Files:

    theANMATOR2b and Doug_B like this.
  4. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    I was wondering about the robot crew seeming like a juxtaposition with an old time theme but forgot to include that in my questions. :)

    Good job on the models. Is it your intention to add textures to the sails - at the moment they look maybe a little under-cooked compared with the rest of the visuals?
     
  5. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Hows the load for the animated characters currently? I suspect it will be more depending on the complexity of the final models, variants and multiple animator controllers playing different cycles and variation offsets.
    BTW - looks really cool. I never really got into any sailing games before - but you've caused some interest here. Kinda cool!
     
  6. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    Thanks Doug_B, good observation! Yes, in fact I already textured the sails of my 2 finished models (a schooner & a cutter). But the brig that you saw on the last picture of my first post is a WIP i.e. the sails need to be done (together with a lot of rigging)

    Here a picture of my model of a schooner (merchant ship / "prey") with textured sails, so can get an impression how the textured sails look like. Your feedback confirms me that the time texturing the sails is good invested time, as it makes a noticeable visual difference :)
    Desktop Screenshot 2018.03.17 - 12.10.57.96 (2).png

    It will take some time to finish the visuals of WIP models (brig, tartane & gunboat) as right now I work more on gameplay. Currently I improve my AI for better pathfinding considering the coast to reach a target or be able to point the cannons on it. The Navmesh of Unity helps, but I am programming an own pathfinding with search trees to consider turning radius of ships, direction of wind, enemies, ... (this cannont be considered by the Navmesh Agent from unity)
     

    Attached Files:

    Doug_B likes this.
  7. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    Thanks :) theANMATOR2b
    The load for the animated characters is 10%-15% when I have 4 ships / aprox. 200 characters in the scene. For comparison the physics of the cloth take 25% of the load, rendering 10%.
    Load for characters depends also from the number of cannons, as they are also animated (a combination of bones and blendshapes, but the complexity shall be low with only 7 bones at most). The advantage with cannons is that I can disable the animation when they are idling i.e. not shooting or moving. When cannons start firing, the load will go up, and during the battle the load will go down as the crew start dying & cannons are destroyed (I disable animations when characters are dead, to reduce the load).
    The ships have currently no animations, but I consider to add them for actions such are using the pumps, droping the anchor, ...
     
    theANMATOR2b and Doug_B like this.
  8. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    That's a great late evening (or early morning?) image - very atmospheric. To me, the sails have quite an impact: changing from just being a mere block of pixels to bringing more life to the overall scene. I would agree that it is time well spent.

    Looking forward to seeing some video of the in-game action. :)
     
  9. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32


    A short combat test between a brig (18 x 18pdr carronades, player) and a cutter (12 x 6 pdr cannons). A bit unfair match ;), but a good way to show these 2 different ship types. It shows the 3 view modes: first person view (moving freely on the ship's deck), ship view & chart view (very shortly). At the end the cutter surrenders (by hoisting down the flag) & is captured by the brig
     
  10. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Hi Aidedecamp. That is looking good. I like the effect of the hull moving through the water with the buoyancy effect.

    Is the movement speed of the vessels realistic, or do they turn faster than they really would to assist with game play?
     
    Aidedecamp likes this.
  11. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    Thanks :) , the buoyancy forces are applied by calculating the volume of the hull submerged (I use a very simplified version of the hull to approximate it) and therefore the movement looks quite realistic (for example when the hull is hit by waves). When I sail with real tall ships I find the movement of the ship under my feet really fascinating.

    The linear speed should be realistic, I have invested much time on the physical simulations. I used speed data of ships of that time to tweak the physical simulation & achieve similar speeds. The speed depending of the angle to the wind behaves also as a real ship, thanks to the simulation.
    For the turning rate I don't have much data & also I don't have easy physical formulas, so I cannot compare too much & I'm not so sure. According to my information a ship can wear in 3 to 5 times it's length, so I try to tweak the turning resistance to achieve this & also have a result which "feels fine".
    What's your first impression about the turning rate? Making it faster could increase the pace of the combat, but would feel to "arcade" in my opinion.

    I hope next time I can show something closer to this ;) (Source: "Master and Commander" movie)

    18268050.gif
     
    Doug_B and theANMATOR2b like this.
  12. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    I thought the turn rate looked well adjusted in the video, I only asked out of pure curiosity.

    I'm inclined to agree with you about avoiding an arcade style. This feels more like a game where the tension should be tangible and allowed to build rather than played out in cartoon speed. To me, the sound blasts you are using for the cannons also help to reinforce that sense of tension.
     
  13. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    I know this isn't a concern until the polish phase - just to mention.
    Everything including sails and even the water - looks too clean.

    Even when ships/boats are 'clean' they still have gunk and muck in the corners and crevices. I suspect - back in that time - gunk, muck and grime was built up quite thick, proly one of the reasons for infections and illnesses in those days.
     
    Aidedecamp likes this.
  14. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    Thanks for the comment, theANMATOR2b, that's a very good point, which I will consider more in the future. The authenticity feeling is very important for me.
    Most of the substance textures I made for my models already include some kind of weathering or dirt: the deck has scratches, the paint defects, the cannons have gunpowder dirt, ... Because substances can be tweaked easily, I can increase some values to make it less clean.
    But the player ship of the video is still WIP, so much of the weathering is still missing, the sails were still using a placeholder texture. I worked on the sails & you can see the difference now with finished. What do you think?
    I would even go further and say that the ships feels too empty. Because it is still WIP some elements on deck are missing. Probably that adds to your impression of cleanliness. I need to add some more clutter.

    I don't know what you exactly mean about the water (too clean). Do you mean the color? Or do you mean not enough foam? Perhaps the missing wood debris created by the impacts on the hull? I considered adding some effects to simulate debris floating on the sea. But that would be really final polish.
    Desktop Screenshot 2018.04.11 - 21.59.28.87 .png
     
    Bartolomeus755 likes this.
  15. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    IMO - the specular is too sharp and too consistent overall the entire water. But - water is terribly tough to make it look 'real'. This is also probably softened in motion.

    The image you provided above - the water seems to look more natural.
     
  16. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    As the cold weather returned to Germany after a busy summer, I've been working again on the game for some weeks :) There are several updates for gameplay, assets & performance, but I'll start with the latest update: the game finally includes a model of the HMS Surprise, which was a special target for long time. From one side this ship was the main inspiration for this game. On the other side it's an important step as it is the biggest ship until now in the game, which forced some performance improvement and the further development gameplay mechanics.

    Desktop Screenshot 2018.11.27 - 23.07.27.52.png
    HMS Surprise in the center with 3 masts (and smaller brig with 2 masts on the right)

    Desktop Screenshot 2018.11.27 - 23.01.39.55.png
    Looking to the upper with the main cannon battery from the quarterdeck.

    The model is still rough (some textures are still placeholders & many details still must be modelled) but it already makes a general impression of the appearance. With this model the workflow was optimized by reusing many components already created for smaller ships ;) (like smaller brig on the first picture).
     
    Doug_B likes this.
  17. HosseinArabbeigi

    HosseinArabbeigi

    Joined:
    May 7, 2014
    Posts:
    16
    Hi @Aidedecamp, well done, nice game.

    we need to buy some ship game source code, if you can help us please contact me by email. thanks a lot.
    Email: h.arabbeigi@gmail.com
     
  18. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    Again after a busy summer, I increased work again on this project!
    There are 3 new functional ships, which can already sail & fight but will need still some modelling and polishing to be finished.
    Below the first new ship, a 74-gun ship of the line, the biggest ship until now :) The target of this addition was checking the performance limits of the simulation because of the greater number of guns and crew models. This forced new performance improvement such as reducing the materials of the guns from 3 to 1 single material, to reduce draw-calls.
    Desktop Screenshot 2019.10.01 - 21.17.18.62.png This will probably the biggest ship in the game (there bigger ones, but not so common). In career mode the player will be limited to smaller ships e.g. frigates. These ships will be the big enemies to avoid

    A complete different ship, the Lugger is much simpler and has a very nice sail geometry for some variance. This ship will be used by privateers.
    Desktop Screenshot 2019.10.01 - 21.19.20.15.png

    And the third ship is bigger frigate of 18pdr cannons, a different model with more guns. In the picture below at the front in a duel with the smaller HMS Surprise model. Desktop Screenshot 2019.10.01 - 22.03.49.79.png

    And finally a couple of pictures of the HMS Suprise model, which looks much more polished and shows the level of detail intended for the newer models (in the future).

    Desktop Screenshot 2019.10.01 - 21.53.10.19.png
    Desktop Screenshot 2019.10.01 - 21.25.49.13.png
     
    Doug_B likes this.
  19. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    Last week the project was updated from Unity 5.6 to 2019.2, which meant some work repairing what got broken o_OUnity2019 doesn't support substances natively and since I created many substances for texturing the ships, I had to install the substance plug-in and reimport a lot of materials. Also the sails stopped showing transparency i.e. no holes were possible, it was an issue with the shader (solved now). The sails started to show the wind pressure wrong, because the cloth component changed how the force is applied and I had to figure out what has changed and modify the sail simulation.
    But finally most problems are solved (only the clouds are still missing) and I can focus again on gameplay, terrain and models :)

    Finally the gameplay is being expanded to include some small arms combat (until now only the ship cannons were used in combat). Now the navy ships can have marines which use their muskets against the enemy crew. These will need still some work, right now the marines are real crack shots hitting the enemy (the precision is too high considering a moving ship and inaccurate muskets) but still don't care if the own crew is on the way and can cause as many casualties in the own crew as in the enemy crew :D

    Bellow a small collection of created props including the musket used by the game's marines.
    WeatherGageSmallerItems1.PNG
     
    Doug_B likes this.
  20. paul_meynckens

    paul_meynckens

    Joined:
    Nov 30, 2019
    Posts:
    4
    Hi @Aidedecamp
    This is a really nice game.
    What I could suggest is to add some canonball trails, because seiing where your crew is shooting is really not obvious.
     
  21. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    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 ...
     
  22. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    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)
    Desktop Screenshot 2020.04.05 - 17.43.56.72.png
     
  23. Aidedecamp

    Aidedecamp

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

    Desktop Screenshot 2020.04.12 - 18.42.06.04.jpg
     
    paul_meynckens likes this.
  24. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    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 :)
    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 :p

    Desktop Screenshot 2020.04.22 - 18.34.59.34.jpg
     
  25. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    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, ...) Desktop Screenshot 2020.05.03 - 21.11.59.43.jpg
     
    Doug_B likes this.
  26. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    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 :D
    Here I can also finally show the 9 pdr frigate in action.

     
    vlBot, GlennCook and Bartolomeus755 like this.
  27. Bartolomeus755

    Bartolomeus755

    Joined:
    Jun 20, 2013
    Posts:
    283
    I like this kind of games. Great work, looks amazing. ;)
     
    Aidedecamp likes this.
  28. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    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)

    upload_2020-8-21_22-46-36.png
     
    GlennCook and Doug_B like this.
  29. VictoryWorks

    VictoryWorks

    Joined:
    Oct 2, 2015
    Posts:
    7
    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.
     
    GlennCook and Aidedecamp like this.
  30. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    Hi VictoryWorks, thanks for your nice worlds about the simulation :) 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 :D, 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 ;))

    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.

    BuoyancyMesh.JPG
     
    GlennCook and JamesArndt like this.
  31. JamesArndt

    JamesArndt

    Unity Technologies

    Joined:
    Dec 1, 2009
    Posts:
    2,912
    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.
     
  32. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    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).
     
    GlennCook and JamesArndt like this.
  33. JamesArndt

    JamesArndt

    Unity Technologies

    Joined:
    Dec 1, 2009
    Posts:
    2,912
    Cool that sounds like a reasonable way to provide control versatility.
     
  34. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    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 :)
    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)
    Desktop Screenshot 2020.10.29 - 22.07.16.23.png

    A xebec (new ship model) close to the french port of Toulon and 2 french frigates leaving it to engage the player
    Desktop Screenshot 2020.10.29 - 22.15.48.99.png
     
  35. GlennCook

    GlennCook

    Joined:
    Oct 24, 2020
    Posts:
    2
    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.
     
    Aidedecamp likes this.
  36. vlBot

    vlBot

    Joined:
    Nov 3, 2020
    Posts:
    2
    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.
     
    Aidedecamp likes this.
  37. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    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.
     
  38. GlennCook

    GlennCook

    Joined:
    Oct 24, 2020
    Posts:
    2
    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.
     
  39. Barretts_Privateer

    Barretts_Privateer

    Joined:
    Apr 10, 2021
    Posts:
    1
    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.
     
    Aidedecamp likes this.
  40. 13E12K

    13E12K

    Joined:
    May 4, 2014
    Posts:
    20
    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?
     
  41. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    Hi Barretts_Privateer, I agree that it's one of the best looking ships of the period ;) That's why last year I started building a prototype of the Prince de Neufchatel (sometimes I build very simple prototype models to get an impression, if a ship type would work for the game) and last week I added the last sails, so I can show how it looks. The prototype has only a hull, masts, sails and the necessary functional components for sailing i.e. no yards, rigging or visual details. Below you can see it sailing near the citadel of Calvi (Corsica).
    Even if the the Prince de Neufchatel was built at the start of the War of 1812, it's plausible that other (privateer) schooners existed before 1812. Therefore it can appear in the game in the Mediterranean Sea before 1812, but with low probability. In fact there were american ships already sailing in the Mediterranean Sea during the First Barbary War of 1801–1805 (example: schooner USS Enterprise)
    What do you think?

    Neufchatel2.JPG
     
  42. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    Hi, I've noticed I haven't posted any updates for more than a year, but the development is still alive. I've been working regularly on completing some of the core features needed for the simulation.
    The most important development during this time has been the implementation of the crew's movement. Previously the crew members would simply warp from position to position (e.g. from cannon to steering wheel). Now the crewmembers can now move within their own ship and also board the enemy ship for hand-to-hand combat :)

    This was quite tricky and needed some experimentation: The navmesh agents didn't work properly when moving on a navmesh attached to the ship's rigidbody. The movement of the ship would cause the agents to drift slowly in the opposite direction to the ship's movement. I tried to compensate the ship's movement by applying an additional translation as the ship to each agent, but there was always a certain shaking and drifting of NPCs. Using the Navmesh functions without the agents allowed the correct movement/standing on the ship, but without collision avoidance, the NPCs would walk through each other.
    At the end the most effective solution that I could find was detaching the navmesh from the ships and keeping at a fixed position. The agents are also detached from the models representing the NPCs and move. The target on the ship's coordiante system is mapped to the navmesh and given to the agent. When the agetn moves, the position is mapped back to the ship's coordinate system to update the NPCs position.

    Below you can see in the editor how the navmesh is in a different (fixed) position than the ship (moving):
    ShipNavmesh.JPG

    The result: NPCs moving free, boarding actions and melee combat (still very basic)
    BoardingCombat2.JPG

    BoardingCombat4.JPG

    Sometimes the least straightforward solutions are at the end the most simple to make work!
     
    Thendash and Doug_B like this.
  43. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    Finally I could implement the last core mechanic for this simulation: boats
    In the age of sailing boats had an important role since ships powered by wind had some limitations. They could be used to tow the ship when there was no wind, for transport between ships and ports and for attacking enemy ships or ports.
    During the Napoleonic Wars "cutting out actions" were very common: a ship would send its boats with armed sailors and marines to attack anchored ships (usually protected by the gun batteries of a port), preferably at night.

    In many old screenshots you can see some boats on the decks of the ships. Now the player can deploy those boats and control directly (i.e. player boards the boat) or let an NPC officer control it. If marines are present on a boat they will use their muskets when the boat is close to an enemy ship, shooting at the enemy crew.
    The perception of the NPC ships is simulated and affected by the amount of light (day/night), size of the ships to be spotted, weather (fog reduces the view range). Therefore in the simulation a small boat in the night can get very close to a enemy ship, before it's spotted and enemy NPCs react.
    The boarding from the enemy ship by the boat(s) still needs to be implemented (at the moment boarding works only between ships)

    Small yawl, only sailors
    upload_2023-5-26_20-49-9.jpeg

    Launch with marines
    Weathergage_220908 Screenshot 2022.09.10 - 21.54.14.42.jpg
     
  44. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,445
    We need a video man :)
     
    Aidedecamp and Antypodish like this.
  45. Aidedecamp

    Aidedecamp

    Joined:
    Nov 22, 2012
    Posts:
    32
    Thanks for the interest :)
    Yes, I am working on a new video ;) A bit different from the previous ones (which were more tests), more editing, a bit more variety.
    But it may take some time yet: the cooling fan of my CPU died recently and with the hot summer, the CPU starts limiting quite soon and the frame-rate drops too much for capturing proper video. But this is a good excuse for a proper hardware update :D (which is taking too long to be available) Until now I was still working with a 10 year old CPU, which was starting to limit the project. So with newer hardware I should have more performance and I should be able to improve some aspects (e.g. increase the amount of ships and/or characters displayed).
    Anyway the reduced performance is making me concentrate a bit more on refactoring of the code to reduce garbage collection or on implementing some unit-tests for the more complex NPC logic.
     
    Doug_B and khos like this.
  46. vintage-retro-indie_78

    vintage-retro-indie_78

    Joined:
    Mar 4, 2023
    Posts:
    285
    looks very cool, and perhaps if there was a cool story, or some ' fictionalized ' events, and one could make a bit of entertainment, and also the historical stuff . . . :) :eek: