ShipWright

A topic by blusails created Jan 22, 2018 Views: 196 Replies: 8
Viewing posts 1 to 9
(2 edits)

This is the beginning.  Finally finished the first iteration of my space/gravity game Orbital Traversal and I'm super excited to move on to something else for a while.

The basic idea is a 2D game, eventually mobile, where you attempt to construct sea worthy vessels out of basic elements using a drag and drop UI and then test them on various levels.  Each level will have a specific set of challenges and goals.  Goals can be as simple as requiring your ship to carry a heavy cargo element  while different water physics/setups can create unique challenges. The ambitious part of this project is to have realistic water/wave physics that interact realistically with the builds.  However, interactive water physics can be computationally intensive - so the challenge is to optimize so that this can be achieved on mobile devices and browsers.  I previously worked with water physics and have some code base to work from.  Here is a tech demo of the 3D interactive water physics I wrote in Unity:

Details can be found here.

To start I had some simple goals:

• Get a simple working UI that allows users to drag and drop build
• Introduce some basic water physics including waves and buoyancy
• Be able to test simple designs

These simple goals have largely been accomplished this weekend.  I wrote some simple scripts which allow the user to instantiate block objects and attach them on any face to other block object.  These blocks are then all tied together using Unity fixed hinges.  Next I wrote an algorithm that reads the surface vertices of some water object and offsets them according to a simple sin wave along with some noise to create some basic wave physics.  The only challenging aspect was real time reporting of the water height so that the block objects could read this height and calculate the buoyancy force.   These basic elements are shown in the gif below (anyone know how to embed large gifs?).

Next on the to-do list:

• Edit UI so that objects can be rotated.
• Add more elements besides the 1x1 block such as:

• triangles
• curved surfaces
• motor
• fuel blocks

Cheers.

(3 edits) (+1)

Here is a wireframe demo of how the wave/object buoyancy interaction works.

The water reports the surface vertices and a buoyancy script attached to each block finds the nearest water vertex and uses it's height to calculate a buoyancy force. The water itself is just a 42 vertex plane (no collider) whose vertices are edited each frame to give the wave effect. The force added is simply proportional to the difference between the water vertex closest to the object and the object transform.

Now if we include multiple blocks, all receiving their own unique buoyancy calculation based on wave height, we get boat movement that looks pretty good:

I initially wanted to move away from physics and just add some additional part components but I'm now working on some code which builds information about the boat after its constructed that could inform even more realistic buoyancy calculations and further down the road allow the boat to take on water.  The first step is to construct a mesh that represents the boats hull and will inform for example how much empty space in the boat is displacing water (which should be contributing more buoyancy). Additionally, I want to know much space is there for water to fill the boat.

(2 edits) (+1)

:]  Sounds really good. With physics I imagine a storm would look very cool. Huge waves and the boat crashing down into the water.

I got my interactive water code to work in 2D, now my boats will have a wake!!

(3 edits)

I've made several small updates,  the big ones required a significant amount of 'dark work'.

(1) A custom water shader which feels like a big upgrade coming from a standard blue shader with alpha.  The shader distorts textures behind it according to a noise map and also creates a nice blue/green color gradient.

(2) I've added a simple propulsion method with a mediocre model/animation, I plan to upgrade all the models as I'll be shifting to art soon.

(3) A realistic drag model (air and water) which takes into account the rendered water surface height,  angle of the objects surface to the water and the relative velocity.  Drag is calculated in all directions.

The result of these 3 elements can be seen in the gif below.  I've noticed that the addition of the drag physics really forces you to create actual boat shaped hulls.  Before when I was testing, some pretty silly designs were super effective.