Alexander Sjögren

Video Game Programmer

Back

Treasure & Treachery

Treasure & Treachery screenshot

Project Info

2024

Unity

12

10 Weeks

C#

Programming


In this treacherous party game, up to 4 players will have to work together to defeat spirits and hurdles trying to keep them away from the evil king. But be aware, only one of you will be able to take the crown for yourself!


About

Treasure & Treachery was made during a 10 week university course (Spelprojekt 2) by a team of 12 students. I was one of the groups three programmers and was mainly responsible for enemy AI and player movement and attack. The goal of this university course was to learn how to work in bigger teams and how to quickly prototype and then choose an idea to complete. Our group ended up making a top down local co-op game for up to 4 players.

Enemy AI

My main area of focus during this project was implementing the enemy AI in the game. The enemies have a variety of states that I chose to implement using a state machine. Each state inherits from a base EnemyState class that contains 4 methods that can be overridden (SetUp, Enter, Update, Exit). The base class also contains a variety of utility methods used by the various states. I created a total of 5 states for the games enemies. In addition to a sate machine the enemies also have two sub-behaviors, one responsible for animations and another responsible for attacking.

Since Treasure & Treachery is a 3D game I decided to use Unity's NavMesh system for navigation. This created a variety of challenges that needed to be solved. Mainly when it came to making the enemies chase the players without hurting the games performance too much. When an enemy is chasing a player the player is constantly moving trying to avoid the enemy. This means that the enemy needs to update its desired position which is a fairly performance heavy task when using the NavMesh system. I therefore decided to only update the enemies desired position whenever the angle between the player and the enemies current target is too great or whenever the enemy was about to reach it goal and the player was further away. With the right values on both of these parameters I managed to make it feel like the enemies were chasing the players without hurting the games performance.

Player

Another area where I ended up spending a lot of time was the player. I was not the only programmer responsible for this area but I ended up writing a lot of code for it. Mainly when it came to the interaction system and the players attacks and abilities. I implemented the interaction system using an interface and the players interaction sub-behavior then keeps track of all the interactable objects within reach and how close they are to the player. The game has a total of 4 characters all with different attacks and abilities. The attacks are implemented using an attack sub-behavior where the designers can easily customize the players attacks to make them feel unique. Since the characters' abilities are all very different from each other I made the decision to implement these separately where each player has an ability that inherits from a base PlayerAbilityBehaviour class.

What I Learned

I learned a lot during this project, mainly when it came to working in a big team of people. Being 12 people in a team means that everyone can't be apart of every decision and responsibility has to be divided between the team members. I also learned a lot about working with other programmers since this was my first time doing so in a project of this size. Overall we were able to cooperate incredibly well and helped each other whenever necessary. In addition I also learned how important it is to have coding standards that everyone follows like how to name variables and so on. This was also my first time working really closely with game designers and I learned how important it is that both the designers and the programmers are on the same page. This avoids having to rewrite a lot of code and overall saves everyone involved a lot of time.

Since Treasure & Treachery is a local multiplayer game with up to 4 players I also ended up learning a lot about how to write code that is more generalized and works with a configurable amount of players. I improved my coding skills in general over the course of this project and ended up learning a lot from the other programers as well. Overall I am really happy with what I learned during this project and I am very proud of the finished game we made.