Make a realistic boat in Unity with C#

2. Build a simple boat scene

Before you begin with the hardcore physics equations, you need a simple scene in Unity. The first thing you should do is to download a script (or create your own script) that will make the camera fly around the scene. You can find one here: FlyCamp Script. If you can fly around the scene then it's much easier to see if everything is working fine.

What you now need to create is two 3D Object Planes, one for the sea bottom and one for the water. You will add waves in the future so don't worry about them for now. My water has a y-position of 0, and my sea bottom is 5 meters below the ocean (y-position -5). You should also remove the Mesh Collider from the water plane.

You also need a boat. In the beginning the boat should be a simple cube. It will make it easier to test the accuracy of the physics equations you will add to make the cube behave like it's floating. Keep everything as it is, including the Box Collider. But you have to add a Rigid Body to the cube. Change the cube's mass to something like 800 kg and the drag to 0.5.

You should also add an empty Game Object child to the cube, and name it something like UnderwaterMesh. To this Game Object you will in a near future add the part of the cube that's below the water. To do that you have to first add a Mesh Filter and a Mesh Renderer to UnderwaterMesh.

To make everything look good, you also need materials. Create 3 materials, one for the water, one for the sea bottom, and one for the part of the floating cube that's below the water. The color of the last material should be like red to make it easier to see. Add the red material to the UnderwaterMesh.

When everything is done, your scene should look like this:


Unity boat tutorial start scene

...and if you press Play, then the cube should fall to the bottom of the sea. But that's not good, so we need to make it float, and that is the topic of the next tutorial.