King of seas

Gameplay:

Play Video

Technical Game Designer & Main Programmer

End-of-year school project 2019

Fantasy Pirate Action Game

Pitch

King of Seas is an action game where you and your crew fight to become the most powerful pirate of the Seas

Development

King of Seas was an end-of-courses project in second year of Aries Game Design School. 

Engine: Unity

Duration: 200h, end of 2nd year school project

Number of people: 3 game designers & 2 game artist.

My role:

  • Character & vehicle designer
  • Gameplay programmer
  • Vehicle programmer
  • AI programmer

The Team

Vincent Vignard
(Game Designer & Producer)

Alexandre Brodu
(main programmer)

Nathanaël Dussaud
(Level Designer)

Yoann Lardy
(3D Artist)

Clemence Bertoye
(3D Artist)

My Work

At first the project was more oriented in simulation, but we realized that because of the small team & the small amount of time we changed for a more arcade genre. We did this also for the sake of the gameplay, we wanted a more dynamic and fun experience for the player and the arcade gameplay has given us less constraint & more opportunities to play with.

As the main programmer of the game I focused on three major tasks:

The Vehicle controller & physics

The Character Controller

The different AI entities

The Vehicle controller & physics

  • The boat reacts to the water via a cylinder collider
  • The boat uses a Rigidbody from the physics of Unity

The boat is divided between 6 parts:

  • The overall script that make the link between all the parts
  • The Physics that handle the floating, moving & turning
  • A Health Manager used to manage the destruction of the different parts of the boat
  • A Minions Manager (see the part about AI)
  • A Cannons manager to let sailors use cannons
  • A Sails Manager to handle the states of the sails

The first floating system:

  • Detect the polygons of the boat mesh that are under water.
  • Apply floating force relative to the normal of the underwater polygon.
  • Pros: more Realist, react better to the movement of the seas
  • Cons: Hard to work around (for the movement of the boat), less performance friendly

In the end I choose not to use this system because it was too complex to work with.

The second floating system used in the last version of the game is similar to the precedent but much simpler & less realist

Float functioning:

  • The float detects the height of the water at its position thanks to the value returned by the Ocean script
  • If the float is under water, it applies a floating force upwards
  • If the float is above water, it applies an additional gravity force
Float system:
  • 4 main floats (front / Back / right & left)
    • They are always in contact with the water, they handle the usual behavior of the ship
  • 3 security floats (Top / Up-right / Up-left)
    • The floats on the sides are used when there are strong waves, to avoid the boat to flip over.
    • The top one is almost never used but serve as a security to flip back the boat on its right side.

Once The ship can float it needs to move accordingly to physics

The sails:

  • When the anchor isn’t lowered there a constant force forward applied to the boat
  • The magnitude of this force is relative of the length of the sails
  • The sails are managed via a state machine
    • 3 state: 0% open / 50% open / 100% open
    • Each state is equivalent to a speed
    • When at 0% the ship still moves slowly forward

The rudder blade:

  • The rudder blade rotates to an angle of 60° (from -30° to 30°)
  • The rotation is controlled by the player acting on the helm
  • When the angle is not around 0° the rudder applies a force at its point on the Rigidbody of the boat
  • This force makes the boat pivot on the Z axis
  • This force Is inversely related to the length of the sails (the less speed the boat have, the more it can turn freely)

The Character Controller movement

  • At the beginning of the project we weren’t sure that we were going to use a Character controller on top of the Ship controller.
  • We decided to use it anyway because we wanted the player to feel closer to the action and to give the order and do the actions themselves.
  • Programming the character controller relative to the Ship Controller was the most difficult part of this game.
  • I made several attempts to have a playable and effective Controller

First attempt – Rigidbody:

  • My first idea was to use two Rigidbodies, one for the character and one for the boat.
  • This gave a bad result because there were too many forces acting on the player.
  • The Character controller was unplayable, it kept falling from the boat.
  • I also tried to replace the Rigidbody of the Character by the Character Controller component already made in Unity.
  • This was worse than anything and it completely broke the physics of the boat.

Second attempt – Dynamic Navmesh:

  • Since we agreed on the fact that the character couldn’t jump and will not leave the boat, I decided to make the character walk on a Navmesh on the boat.
  • This Navmesh was baked dynamically on the boat and was updated every time the boat moved.
  • It was a functional solution at first, but I add problem when adding Sailors AI on the player boat.

Final attempt – Static Navmesh:

  • To resolve the problems, I had with the controller, I used a convoluted solution.
  • There are now two boats
    • The first one is static and has the Navmesh baked on it and a basic controller walking on it
    • The second one is the physical boat that moves in the world an it have the Second character controller that have the animation and the camera
  • The player controls the entity on the Static Boat and its position relative to the static boat is reported on the “real” controller moving on the “real” boat.

The Enemy ship AI

Making the AI of the enemy boat was the second most challenging thing I had to do for the project for one particular reason:

I had to use the exact same physics than the player’s boat.

The movements:

The solution implies the use of a Navmesh agent separated from the ship:

  • The agent follow an usual agent path on a navmesh.
  • The ship, then use it’s rudder blade (as explained earlier) to always face the agent.
  • The ship use a front detection (the red lines shown on the video above) to modulate the lengh of the sails in order to avoid collisions.
  • The sails also help the agent and the ship to stay at a close distance and not to far away
Enemy ship state machine

The State Machine:

I used a state machine because the behavior of the enemy ship is simple:

  •  The ship follow a patrol until the player enter its detection range
  • The ship chase the player until it reach on of the sides of the player’s boat
  • Once the combat range reached, the ship start using its cannons
Top down view of the behavior of the enemy ship

The Cannons:

Because the enemy ship use the same mechanics of the player’s ship I had to find a solution for the aim of the cannons :

  • I started by using a Bezier curve depending on the distance of the player
  • But the Bezier curve was too complex to use with all the other elements of the physics
  • In the end the cannons work with a simple math operation depending on the distance of the player
  • It’s less accurate but I think it works because the enemies are not supposed to hit the player everytime

The Sailors AI

The sailors were here to give more life to the game and to reinforce the feeling of being in control of the ship.
they were divided into three groups:

  • The Gunners: they work on the cannons.
  • The Bucanneers: Originally the ones boarding the enemy ship (feature not implemented).
  • The Sailors: the ones repairing the ship and controlling the sails.

They use the same system as the player character to move on the boat.

The State Machine:

They also use a simple state machine:

  • They wander aimlessly until an order is given.
  • they move to the requested position (cannons, masts etc..).
  • they execute the action until the action is done or until they are given a different order.