No one knows what caused it… Simply one day the world as we know it was washed away. No hospitable land remains for humans to set foot upon. The survivors of the apocalypse eak out a desperate existence living on ramshackle boats and floatings scrap heaps.
However, hope still remains for a small group of survivors, searching for the rumored last peak on earth…
Last peak is an open world boat combat game which features a custom water and buoyancy system. You play as the captain of a small ship looking for your lost crew and fighting other hostile boats for survival.
I wrote everything located in the boat folder.
We used perforce for this project so the github commits are not an accurate representation of the commit history
The Water System
An early prototype of the water system
Proof of concept for the FloatComps
The water system was the result of a great cooperative partnership between our shader programmer Nelson Kossuga and me.
The floating components (FloatComps) can be seen in action in the top two gifs as the tiny spheres attached to the sides.
When above the water a gravity force is applied on the FloatComp which gradually increases in magnitude over time. When below the water a constant buoyancy force is applied to the FloatComp, the force exponentially grows the deeper the FloatComp gets.
My FloatComps send their current X and Y coordinate as well as the world time to Nelson’s math function in order to generate a Z height that represents the water surface line. The math function contains the same equations as the shader does. This way we can make sure the water shader’s visuals are synced with the game’s physics. Which allows us to measure if a FloatComp is above or below the water shader and determine what to do with it.
The final version of the water system
A video showcasing one of the boats moving on the water
The boat movement is deceptively complex. For the sake of simplicity I wanted to treat the game like a 2D game, where the waves determine the height of the boats location. This meant that the player would only affect the boats X and Y position and yaw rotation, while the waves determined the Z position.
To achieve this the boat is split into several moving parts:
- The Root: determines the boat’s yaw rotation.
- The Physics Body: determines the Z location of the boat and the pitch and roll rotations of the boat mesh.
- The Push Collider: determines the boat’s X and Y location.
The movement acceleration is done using math to determine its velocity on a 0 to 1 scale multiplied by a max speed. The boat operates on gears and each gear reperesnts a constant value on the 0 to 1 velocity scale. Similarly turning velocity also uses a number scale except it is a -1(left) to 1(right) scale, so that we can achieve a heavy feel when you are turning the boat.
Some early footage of the boat collision veering
Crew And Health Sections
Crew being shuffled around the ship's health sections
A damaged health section being repaired
The boat’s systems are divided into health sections Left, Right, Front and Back. Each section collects references to damageable systems such as guns and engines located on their section. When a health section is reduced to 0 health the damageable systems located on that section break and are either disabled or stunted until the section is repaired.
The player can move crew around the ship to different sections, having crew in a section improves its performance and allows it to be repaired over time.
The medium boat being upgraded to the large boat
Originally we intended to have an upgrade system where the player could choose to upgrade guns and armor on each section individually. However as the project progressed it became clear that it would not be feasible if we wanted the other features we had planned.
Therefore the upgrade system was scrapped and features from it were incorporated with the crew system. Collecting enough crew now gives you a better boat with more armor and better guns.
Guns And Camera Shake
A video showing the guns remaining horizontally aligned when turning
A video showing the camera shake and gun shooting
The guns are pretty simple, they use a line trace on a specific channel to see if they hit something that blocks the line. The guns have a couple stats that can be changed on each instance like damage or rate of fire. The guns are seperate actors that are spawned and attached by a seperate component on the boat, the GunDriverComp. It is very easy to specify on the GunDriverComp what guns the boat will spawn with, meaning it is simple to make new boat and gun combinaitons.
early footage of the guns firing
Inputs are sent from the GunDriverComp to the guns. Whenever a gun is fired, the GunDriverComp adds trauma to the CameraShakeComp.
The CameraShakeComp exponentially shakes the camera based on trauma. The shake that occurs rotates the camera using an offset calculated from the trauma, and adds it to the original rotation. Trauma continually gets reduced and eventually reaches 0 at which point the rotation offset is also 0. The big benefit of this system is that trauma can be added to cumulatively, meaning different things can each increase the screen shake without messing up a shake that is already occurring.
The camera setup is as follows:
- The Camera Holder: determines the camera’s yaw rotation.
- The Camera Arm: determines the pitch rotation.
- The Camera Comp: is what rotates when the camera shake is occurring.