Nautikin Adventures

Nautikin Adventures

Not enough ratings
How to Make a Mod
By Revmatek
This guide will cover the current modding behaviors / APIs that are available for making different types of mods and will be updated with new support when it is added. There is a certain amount of knowledge or expertise assumed in this guide and it will not attempt to explain how to use various 3rd party software.
   
Award
Favorite
Favorited
Unfavorite
Prerequisites
There is some software that is needed for creating mods
  • Blender
  • Unity
  • Webm encoder (optional)
Some of this software can be very complicated, more so probably then the game itself. In terms of making things in Blender, not much will be explained because there are plenty of how-to guides out there (Blender forums, YouTube, etc.) for making models or whatever you want to make. For the purposes of modding this guide will touch on the elements required to make your model work with the game.

For Unity, very little will be explained other then the buttons you need to click to build your mod.

Once you have some basic knowledge about the software above you are ready to proceed! If you wish to proceed without any research you may do so, however you will definitely encounter information where you will have to stop reading the guide and go figure out how to do something specific.
Getting started
The first thing we need to do is find the mod tools. The mod tools are located in a folder aptly named "ModTools" in the install directory for Nautikin Adventures. The install directory may vary based on how you have Steam configured or the platform you are on. In general you can locate it immediately by browsing for the local files in Steam.
The next thing we need to do is point out the readme. The readme is located in the "ModTools" directory mentioned above. Without performing the steps yet, just keep in mind that this readme exists and may contain information in the future that changes.

Moving on...

1) Download and run Unity version 2021.3.26f1 or later 2021.3 LTS
The installation of Unity will not be explained, it should be pretty straightforward.

You can find specific versions of Unity either by searching for them on Google or directly here:
https://unity.com/releases/editor/qa/lts-releases

More specifically we want this one:
https://unity.com/releases/editor/whats-new/2021.3.26

The reason we want a specific version is to maintain some sort of compatibility baseline, versions of Unity can vary wildly in functionality and featured bugs. This just limits the possibility of things not working for version mismatch reasons.

So at this point you should have Unity Hub and some version of Unity installed, now we are going to diverge a little bit from the readme and install Blender. If you already have Blender installed you can most likely ignore this part. Once again the installation of Blender is not going to be explained because it should be pretty straightforward.

You can download Blender from:
https://www.blender.org/download/

A known working version:
https://www.blender.org/download/releases/3-1/

The version of Blender is not terribly important because Blender has been mostly the same for years and tends to be stable. You may use other modeling software if you want as long as it supports FBX exports. For the purposes of this guide we will use Blender.

2) Import "NA_ModTools.unitypackage" with "Assets->Import Package->Custom Package..."
The readme is telling us we need to open Unity. So if you have not done so, open Unity and create Project with whatever name you desire (e.g. MyFirstMod). Once the Unity project is open we need to import the mod tools. We can do this from the top left of the editor.

Assets->Import Package->Custom Package

Select the package in the ModTools folder mentioned above.

Click import
Note: The items in this window may be expanded, this is how you will update the mod tools in the future.

Ok, now we pretty much have everything we need installed with the exception of a Webm encoder, which will not be explained, but mentioned later.

3) See readme in "Assets/_pNautikinAdventuresModTools"
One last thing we need to look at before we start making a mod. There is a second readme that contains some technical vomit for various things related to creating mods, you can just skim this file for now as most of this should be covered in later sections.

You can locate the readme in the editor from the Project window (which should be in the bottom left by default):
Note: You can open this file by double clicking on it or by observing its contents in the Inspector panel on the right.

That should be all the information we need to start making a mod. You can now move onto whatever section you are interested in.
Importing a custom model into Unity
Create the desired model in Blender
Congratulations! 🥳 You have mastered Blender and created a model that you intend to use for a custom part. (This guide will not explain how to make models 🤣). You may proceed with this section with any convex models. For concave models you will have to follow some additional steps in a later section.

For the this example we are using an Icosphere:

Exporting your part as an FBX
In order to export a model for Unity to use we need a FBX format file. If your version of Blender or other modeling software does not support exporting in FBX for some reason you will need to go install a plugin or something.

The important part for this game is that the export settings are correct and the coordinate system lines up correctly when we load the file into Unity (Blender and Unity use different coordinate systems / axis). This may involve applying some sort of rotation fix to adjust for the 90 degree default export Blender likes to do. I use a script for this that you can probably find to make your life easier. You will have to install an add-on / plugin or manually apply the rotation (which you can google, admittedly it can be confusing). You can also ignore it, it will just have a odd rotation in Unity when imported later. But for more complex parts (things that move or sub meshes / children) it will definitely cause problems and will require some trial and error to get the desired rotation.

When you export your model, you will probably want to create a folder in Unity to organize your mod files.
Unity Tools (blender plugin)
Export settings
Note: You can modify these settings as needed, one important part is the selected objects if this is not selected make sure you have deleted the default camera and lighting objects that Blender creates or selected the parts in Blender you want to export. You can also save your export settings using that + button

Note: Exported models should result in a scale of (1, 1, 1), and rotation (0, 0, 0). When imported by the game later this will be validated and trigger errors. Some build features may not work unless it is fixed.

Note: UVs should ideally be less than or equal to (1, 1). Increasing above that may cause weird behavior with part scaling or destruction

Note: The pivot / origin of your mesh should ideally be centered with the volume of the mesh. This will determine where the adjustment arrows appear.

After you export your model into the Unity folder (if you can't find that you can right-click and say "Show in Explorer") we need to change some import settings for the build system in NA to use.

To change these import settings, click on the model in the project explorer
This will activate the inspector window for the model on the right side of the editor where we can tweak some settings
The important parts we want to change here are:
  • Read/Write - This needs to be true so that the build system can modify the mesh at runtime. Not doing this will likely break the game.
  • Normals - Calculating normals tends to avoid having a blocky appearance, you can use your own if you desire.

Make sure you hit "Apply" after changing these settings to trigger a re-import of the model.

That's it, Unity is now ready to make use of the model.
Exporting your custom part with Unity
Now that you have a model imported into Unity we can configure a few things for NA to use.

The first thing we need is a prefab. In order to make one we are going to create a new empty scene (which you don't need to save)

In the top left select File->New scene and click create
Drag your model object into the scene window or hierarchy window from the project window
Now we need to add a script for the game to understand the part, with the part / model selected in the scene the inspector window on the right will activate with the script context. We want to add a component that has been included in the mod tools.
Once the script is added you can change whatever desired settings. If you hover over the flags / properties on the script you will be able to see descriptions of what those properties do in the game. These scripts will be expanded over time as more features are enabled / supported for modding.
Note: the ID is automatically generated and you should not have to mess with it. This is an internal value for distinguishing parts in the build system.

Once this is done, we need to create a prefab from the model / object in the scene we just attached the script to, this can be done by dragging the object back from the hierarchy window into the window where the model is located and selecting "Original Prefab" when prompted
Now that we have made a prefab, we no longer need the scene or the object in the scene linked to the prefab. You can delete the scene by opening something else and not saving, but it is easier to just delete object in the scene for now and ignore the scene later. You can delete the object by selecting it in the hierarchy window and clicking [Delete] on the keyboard. Not deleting this object will cause errors in the build later.

In order to roll these objects into a mod we need to tag them so that they get included in the asset bundle, which is essentially the mod. What we are looking for is the AssetBundle tag at the bottom of the inspector, Not the game object tag at the top.

First select both of the files we have created (ignore my 3rd webm file for now, that will be covered in a different section)
When you select those the inspector window on the right will again activate context for the two objects. In the bottom of that window you will see some really goofy double lines running across next to "2 Game Objects"
If you click on these goofy lines it will reveal a super secret embarrassing panel from the Christmas party.
This is where we need to add the tags. Your tags should be defined per mod and named whatever you want your mod to be named. If your mod includes multiple parts you could simply call your tag "MyCoolParts" or something. For this guide the tag is called "MyFirstMod", this will always be made lowercase and does not matter.

With the objects tagged (the model and the prefab) we are ready to attempt a build. I say attempt because if at any point you did something wrong it may fail (or if I left something out...). Included in the mod tools is another editor script that will automatically process any tags you have defined into runtime mods / bundles which are essentially containers / zip files that the game can read later.

To start this process select Tools->Nautikin Adventures->Build Mod
Note: this may take a bit depending on the size of your mod

If this completed successfully, you have created a mod! 🎉The mod files will be dumped into "ModOuput"
These are the only 2 files you care about for your mod, one is the manifest which tells the game what is in the container and the other is the compiled objects.
These can be used later to load your mod into the game.
Testing your mod in game
So we have made a mod and we want to make sure it works or otherwise test something we changed. This is where you will find out for sure if your model was exported correctly.

In the last section we made these 2 mod files, a manifest and a container. We need to move these files into a folder matching the name of the mod.

In

C:\Users\[username]\AppData\LocalLow\Revmatek\NautikinAdventures\Workshop\LocalMods

Create a folder named "MyFirstMod" or whatever your mod is called. In that folder, copy and paste your mod files. If this direcotry is not there, you may need to run the game first.
Now you can start the game. When you load any save you will see something along the lines of "Loading mods..." which will indicate mods are loading.
If your mod loaded successfully you will see it appear as a duck or webm preview if you already made one in the dry dock or runway.
Note: If it did not appear there may be barf in the Player.log located several folders up. You may have to double check previous steps. If you subscribe to your own mod while the local folder is still present your mod may appear twice.
At this point it should be pretty easy to test that your mod is working correctly. A couple things I would look for:
  • Is it facing the right direction
  • Do the colliders work when I walk on it as a Nautikin
  • Can I place other parts on it
That is about it. Now you have a working mod part to play with, later you can upload it to the workshop if desired.
Creating a preview for your mod
This part is optional, but you probably want it if you are planning on uploading to the workshop for others to use.

Icons
If you want to add something simple, you can make an icon with the same name as your part and save it as either a jpg or png in the same directory as the part, similar to the way the webms are saved below, if you don't want an animated icon you do not need a webm. The TV and Painting example mod parts have icons created if you need a reference.

Webms
The previews for the mod parts are formatted as WebM VP8 (Unity does not support VP9, we want small files anyway). This guide is not really going to explain how to encode webms, there are plenty of how-tos out there and even more tools. Really what is important here is that the frames exported from the scene are packed into the webm.

To generate part webms:
  1. Open "./AnimatedIconMaker/AnimatedIconMaker.unity" scene
  2. Import TMP Essentials, reload scene
  3. Set display to 1920x1080
  4. Place your model / part inside the frame with "RotationRoot" as the parent and move RotationRoot accordingly to position inside the frame
  5. Read the instructions on the screen
    Following these instructions will create a bunch of frames in a folder that you can use to generate webms. I use Adobe Media Encoder with a Webm codec but you should be able to use other tools to process the frames. Technically you can make whatever webm you want (See Steam rules for workshop content.).

  6. Use an external tool to generate a webm using the output frames (e.g. Adobe Media Encoder (webm), many other tools exist)
  7. Rename this webm to match your part name and tag it with your mod / asset bundle
Note: Ideally your webm should be less than 100 KB in size, larger files may reduce runtime performance

Once you have created this webm you need to move it from the output folder and rename it with the same name as the part. Additionally you must tag it for the bundle as done previously for the model and the prefab so that it is included in the mod. Once that is complete, rebuild your mod.

FFMPEG
To create a webm with ffmpeg, you can use this command:
ffmpeg -framerate 30 -i temp_frame_%04d.jpg -c:v libvpx -crf 20 -b:v 500k -pix_fmt yuv420p output.webm
Uploading your mod to the workshop
Your mod is done and its awesome! 😎

You can now upload it to the Steam workshop! To do this you must move your mod to a special folder so that the game can detect it.

Place your mods files in a new folder at
C:\Users\[user]\AppData\LocalLow\Revmatek\NautikinAdventures\Workshop\WorkshopUploadTemp

To create a preview image for your mod add a MyFirstMod.jpg to the mod folder prior to upload / update. The name of the preview must match your mod name.

Start the game, then open the workshop tab from the main menu (settings, top right) and follow the instructions for the upload / update mod wizards.
That's it! After that you should be able to edit your mod in the workshop with whatever screenshots you want.
Colliders
Requirements
  • All runtime colliders will be made convex in order to support PhysX
  • If no keyword colliders are provided the mesh will be used as the default collider and made convex, this will cause strange behavior if your mesh is concave
  • You can provide a keyword collider whose name contains "ColliderMain", this will be used for various build functionality / placement / runtime ray casting
  • For concave meshes you must provide additional mesh objects whose names contain "Collider", these objects will automatically be used to generate collision meshes for runtime
Warnings
When you export an fbx from Blender it should include desired detail for the part (mesh) and any additional colliders (also meshes). Colliders that have too many polygons may result in warnings in NautikinAdventures.log which will say things like "Convex Mesh Colliders are limited to 255 triangles" which is bad because it means every time the game uses an instance of your part it will slow down the game simplifying the mesh for the collider. The message here is that if you are making a detailed mesh, the colliders for it should be low poly / approximations, not just a copy of the high vert mesh.

Lists
For some of the more complex mod parts like ship engines, you can supply a list of game objects that you wish to have generate colliders. In those cases you do not need to define keyword colliders. This is useful for when model geometry is simple enough to generate a high performance collider. Using this to generate colliders for complex models (many triangles) can result in warnings.
Concave mod parts
What is concave?
adjective: concave:
having an outline or surface that curves inward like the interior of a circle or sphere.
"concave lenses"

Here is an example, I have made this part that I intend to use in a mod
This is clearly some sort of block stair thing. But more importantly, it is concave, not convex. PhysX, the physics engine used by Unity (and Nvidia cards in general, or whatever engine) require moving objects (Rigidbodies in this case) to use convex colliders for mathematical purposes (namely that apparently it still lights computers on fire were it to be concave). Anyway, what makes this shape concave? For starters its missing a big chunk of cube right there on the top! That means that when the physics engine tries to wrap it in plastic wrap like a sandwich to generate a collider there will be a gap where that square is missing and if you try to stand or place something on it, it will appear to float above it erroneously instead of flush with the surface of the mesh.

So how do you the modder fix this? Good question, the easiest way is to create duplicates of your mesh and make them children in blender. The duplicates should be cut up into chunks that represent each section of a concave collider that should be used for the part. Many of the hulls in the game do this (e.g. the racing hull).

In this example I need 2 colliders as children.
These 2 colliders will essentially become a singular collider for the object that is convex instead of concave. These are what are know as "Keyword Colliders" for the mods. The mod loader will detect objects that your mod has named with "Collider" as a collider and also look for "ColliderMain" for build system reasons. Collider main should be whichever collider is largest and or most centered.

When you export them they should be in this structure, which you can accomplish by selecting the desired children with the parent selected last and pressing CTRL+P, then keeping transform positions.

That's about it. Just be mindful of concave vs convex and breakdown you mesh into separate meshes for low poly colliders.
Buoyancy Proxies
A buoyancy proxy is a substitute mesh to be used for water simulation and buoyancy math.

There are a couple reasons why you might want to use a buoyancy proxy:
  • The mod part is very detailed / high poly
  • The mod part has concave surfaces

Buoyancy proxies allow for more approximated water forces to be applied to concave shapes that would otherwise have difficulty floating or would not realistically float but need to float anyway. Parts can have proxy meshes which represent the target the water simulation will evaluate in order to either simplify the math or otherwise alter the outcome. Examples of this would be any buoyant mesh that has concave surfaces inside of it such as an open doored aircraft hull or an animated part that curves inwards in order to support animation, but would in reality be water tight. The mod loader will search for a keyword "BuoyancyProxy" similar to "ColliderMain" when parsing the mod parts. In cases where a buoyancy proxy is needed but not supplied behavior may occur where vessels with said part can get stuck underwater due to anti-buoyant forces being applied to the concave interior surfaces either counteracting or overpowering exterior convex forces.

Note: Similar to colliders, mods support multiple proxy meshes. Supplying more than one mesh with the name containing "BuoyancyProxy" ("BuoyancyProxy1", "BuoyancyProxy2", etc.) will automatically combine them into the water sim.

Here is an example of a boat hull that is concave in some areas:
For the most part, this works fine. It might be a little slow math wise depending on how many triangles are on the mesh. In this specific case, the concave front of the hull (while looking cool), can be misinterpreted or treated as sinking forces when water presses against it after a vessel has sunk. This may result in strange behavior such as the vessel appearing to float towards the surface, but also being stuck on the sea floor. This happens because as far as the math is concerned, the concave portion of the hull is flooded (which it is), so forces are applied, these forces are bound by the limits of the physics engine and having fast math / high performance, so in this case we need to give it some help so it doesn't have to do extra work or get confused. One other consideration is that this proxy will be updated when the vessel is deformed from crashing into a wall. So by making it simple we also save some performance with the deformation process.

To make this mesh concave and give it a proxy, we can modify a copy of the mesh in edit mode
The easiest way to reduce the amount of triangles for a mesh would be to use the "Decimate" modifier in Blender. Since this mesh is never visible, you can reduce the ratio as you see fit. Just be sure to test it in game. As long as the proxy matches the general shape of your part, its probably fine. You can also make it a completely different shape if desired.


You can check the polygons using the stats in blender:

For this part, I have created a bouyancy proxy called "RacingHullBuoyancyProxy" which is a child of the part being exported, because it has "BuoyancyProxy" in the name, it will be auto detected for water simulation when being loaded into the game later.


The final shape of the mesh is now convex and has far less triangles.
Subscribing to a mod
To subscribe to someone's mod, simply click "Subscribe" in the Steam workshop page for the mod and the next time you load a save the game will load it in.

Some special notes about how that works for servers. Servers hosting a game with mods loaded will automatically trigger clients to download those mods temporarily in order to join the game without missing parts. The only exception to this right now is subscribed vessels. Vessels that have mod parts in them will not automatically download said parts. So any mod parts you use in your vessel you need to list on your vessel workshop page I guess. This may be supported automatically in the future.
Examples
The mod tools contains a few examples of different things you can do with mod parts.
Note: None of the examples are tagged for building by default to prevent accidental output.

MyFirstMod
This is a part that was made to drive the implementation of the original mod tools, but serves as a good example of how to setup all the pieces correctly

Painting
This part serves as an example of how to make mods with custom textures. Any mesh that is not part of the main mesh (the root) will retain it's original material. The root part is used for applying the build mode materials (Steel, wood, etc.). The model in this example has an embedded material exported from Blender "DolphinFacePainting" which simply has an Albedo property set to the "dolphinface" image. You can make you own custom images and setup the materials as desired.

TV
The tv is a simple model setup with a video player to playback and loop a webm. It supports sound but the example webm does not have sound. This should support any codec / video format Unity supports.

Complex parts
Some of the more complex parts like ship engines or aero dynamic wings have examples in this folder as well. Most of the examples use simple models that are made for illustration purposes, the intent is that when you make your own you simply follow the pattern laid out by the examples which includes things like model hierarchy and how the scripts are setup.

Complex examples often make use of lists where objects must be supplied to the script. This includes things like colliders or certain parts of the model you want to move. So it is important to examine the example prefabs carefully (or ask questions on Discord). Most of the configuration options have tooltips that will tell you about what they do. These mod parts use scripts that inherit from ModPartInfo, you can see the available mod support by looking in the ./Scripts folder. A mod part should only have one script attached, if you use ShipEngineModPartInfo for example you no longer need ModPartInfo.
Additional mod support
If a desired feature or mod API is not listed in this guide or shown in the scripts, it may not be supported.

If you would like to request something specific you can reach out to me on Discord or start a Steam discussion and I will see what I can do about prioritizing it.