Christos
Embark

Introduction
Embark was the second project in my time in TGA, where we had to make a mobile game in Unity. Since I had most experience in Unity, I took the gameplay and water shader to work on during the project. I also helped with the music.
Water Shader
In the game we had to have a water that would fill when the player completed a level. Since the goal of the game was to manipulate the path so the bark boat could flow through to the end.
To achieve this we had a plane that matched the tile model, and used a shader to manipulate the plane.
We had three different shapes that a tile could be:
-
Straight
-
Curved
-
T
To make the water rise, the plane had a shader attached to it that we could then send in a texture we created. This texture went from black to white in a certain direction. The black and white decided in what direction and how smoothly the water would rise, if we wanted the water to rise from the opposite side, we could just rotate the plane 180 degrees.
This of course depended on how the tile was rotated and from which way the previous tile water came from.

(One of the first tests with the water shader)
This of course works great on simple straight tiles. But another texture would be needed to be created for curved tiles, since the curved tiles needed a more precise direction in the texture.

(The water in action with straight and curved tiles)
The T tiles were the hardest tiles to get right and I tried many different textures and ideas but none of them worked. I decided it would take to much time and work to make it work, so I just let the water rise from the middle and flow towards each entry point. This way I wouldn't need to create a new texture for every entry and possible collision. But the final result does look good and it wasn't to distracting having it come from the middle.

Animating the tiles
In the game the user would click on a tile and the tile would then go up, rotate 90 degrees and then go down in a smooth and juicy movement. To achieve this and give the animators the power to be able on their own to tweak it, I used unitys animation curves.
I then linked each curve to a specific property like the rotation of the tile and the position of the tile in the y axis. With this the animators would be able to much easier control the accelerator of the object.

(curve for the translation of the object, y decides how high the object goes, based on its world position)

(curve for the rotation)

(tile in action)
Finishing a level
To complete the game the player would have to have a clear path to the end. Since the bark boat starts at a start tile and wants to get to the end. Figuring out if the player had opened completed path was a bit difficult, since you need a algorithm to check so all the tiles reached the end.
To save computing power I decided that each time the tile rotated, it would raycast around the tile to see if any other tile were there. And if there was I would check if the tiles connected.

(The white lines that appear after the tile lands, are the raycasts)
That's also how I figured out how to properly align the water shader, since when I raycasted I got access to the other tile and was able to calculate its location around the tile and rotate the plane accordingly and based on which shape the tile had.
When the last tile was connected with the path. The level would complete and the player would be able to enjoy the water flowing through the entire path and the bark boat making its way to the end.

Play
The game is free to download on the android store, so feel free to play it, if you liked what you see here!
