Branch Battles

Branch Battles is a Real Time Strategy game created entirely by me in Unity. I worked on this project from January 2023 to September of 2023 before posting to Itch, and still update the game with playtester feedback.

preview

Play Now

Overview

Train miners to get gold, use gold to get soldiers, use soldiers to get victory.

Contributions

Game Designer

This was my first solo game, and having total control over it was both relieving and terrifying. I decided to make a game that was somewhere betweeen two of my old favorites Stick War and Age of War. I felt that the mechanics would be easy enough for me to recreate the core gameplay loops, and open-ended enough to add on my own spin.

Movement Style

On my original game design document the plan was to have one dimensional troop movement like in Age of War, but offer the player the more strategic elements of defending like Stick War. I also wanted to have multiple levels to offer diverse challenges to player and avoid a single long game. After the original prototype was created with 3 different player soldiers, a miner, a defensive sniper tower, and gates I came to my first real design challenge. The one dimensional gameplay didn’t feel fun, and playing levels felt extremely slow and disintresting. After a few playtests I decided to go two-dimensional with the movement for the sake of a better player experience. By switching the entire combat system to be two dimensional, there were far more bugs, weirder troop behavior, and a lot more programming effort, but from the very first prototype the game felt infinetly more fun to play.

The General

Another important desicion was increasing the player’s engagement with the game Managing the army composition and position was fun, but in the early stages of the game, the player was spending far too much time watching, rather than playing. Again, I turned to Stick Wars for inspiration, and allowed the player to take control of a unit on the field. But rather than switching between multiple units, I decided to create a single avatar for the player on the field, the General. The General required a lot of iterations and playtests to balance his utility in battle as well as improving the player’s experience. The final result included the following abilities and limitations:

Gneral AOE

Capable of wiping out a large number of enemies

Gneral Healing

Forced to return to tent throughout levels

Gneral Orders

Charging soldiers will return with their shields or on them

Game Modes

Level design was an extremely enjoyable task at the end of the game. I designed a total of 4 game modes, each with slightly different win and loss conditions:

Standard Battle Layout

Destroy the tent to win

Standard Battle Layout

Survive until the timer reaches 0

Standard Battle Layout

Something is going to come out of that, and it could be a lawsuit

Soldiers

Army design - Rather than unlocking every soldier to be used in battle, players a constrained to choose a maximum of four soldiers within a battle. Players are thus forced to developing strategies before battles, and allows for more soldiers to be added without being overwhelming.

Damage Calculations - In order to calculate the damage a soldier receives, the attacked unit’s armor functions as a threshold. If the damage exceeds the armor, the full damage is received. Otherwise only a fraction is received. This effectively creates a type matchup chart between units based on damage and armor, while using attack speed to calculate a seperate DPS.

This was my mentality for each of the soldiers - I really like all of them, so forgive me for discussing each of them in length (as well as offering a couple of strategy tips):

Shield Wall

A phalanx is created to overwhelm the low damage per hit Fighters

Rage

Every head is a nail if the hammer is big enough

John Wick

Truly the Baba Yage of Branch Battles

Artist

I will preface this section by stating that I am not an artist, and wouldn’t consider any of the pixel art I made to be good by professional standards.

With that said I am extremely proud of how the art in Branch Battles turned out. I was able to create buildings, multiple units with unique designs and animations and backgrounds with parallax layers.

Working on the unit animations required a lot of my time over the summer, but allowing each unit to move and feel different was extremely important to the finished game.

My process for creating these constantly changed, but here are some of my favorites. I typically leaned into a slightly humourous side to some of these to compensate for the lack of detailing I was able to offer.

Also, learning some basic shaders was a huge addition for my game, and really helped complement the art I had already done. The shader I used the most edited the colors of the units, which I used to differentiate the player units from the enemy, as well as giving the boss units clear differences, without requiring extra effort.

Game Programming

Fundamentals

In order to make the rest of the explanations make sense I first need to describe the main functions that go into the gameplay loop. The player and opponent each have a TeamInfo script that is responsible for storing the variables of each team, training and moving troops, and using magic. The player has a script that interfaces to the team info with the player’s inputs, and the enemy has a script that functions the same, but based on an AI’s decisions. The TeamInfo trains troops at the set barracks location, and units will then proceed to the rally point, which is changing throughout the game.

The hierarchy of inheritance for damageables is also important, certain bypasses in attacks and spells, and making the code easier to work on.

Damageable Hierarchy

Unit Behavior

The Unit behavior is what I would consider to be the single most important part of this game. Units needed to act rationally and the scripts needed to be flexible enough to give each unit type unique behavior.

The functionality I needed for a series of soldiers to function as a cohesive army are as follows:

I decided to implement a code based Finite State Machine to control the units AI. I used a FSM because I could simplify a units behavior down to four states: Walk, Retreat, Wait, and Attack. I quickly realized that the functionality within Retreat could be handled within Walk, and later on added Charge as a seperate state.

Each unit is given a class to determine the organization of an army. Front soldiers, like Shields, have a low class number, while soldiers with a longer range have high class numbers, such as Archers. This made it very easy to organize armies into groups of soldiers, as well as making it simple to add new groups later if I add new units.

The key checks to determine transitions include if an enemy is agroable, if an enemy is attackable, and if the unit is in its assemble range.

State Machine Overview

Save System

The data that is actually saved only contains 5 elements:

Started Started GIF

Early Game

This data is then passed into a static PlayerInfo class which is used throughout the game to provide the needed data to the games systems. By decoupling the systems I don’t force the player to reset their progress to play a new game, and unlike old Pokemon games, they can override their data whenever.

This feature was especially useful for myself while testing and developing as I could access every unit and level, but also test out the game flow by restarting, without wiping my finished save.

Finished Finished

End Game

Level Creation Process

An ongoing development process was making it as easy as possible to setup new systems within the levels. Here are a few of the improvements I made overtime.

Combining these with occasional code refactorings really helped me to maintain a flow throughout the duration of the project, and darastically speed up production time.

Barracks

The Barracks is only a single scene, but its existence is extremely valuable to increasing the depth of Branch Battles to players, and developing functionality common amongst video games.

Creating the stat wheel forced me to learn about how to use tiled sprites, as well as implementing an outside script to generate a mesh based on a polygon collider.

Stat Wheel

Enemy AI

In game there are two main Enemy AIs: Survival and Standard. The countdown, standard, and boss levels all use the same AI, with certain values tweaked to create different behaviors from the player’s perspective.

Survival AI is relatively simple. I have groups of preset waves, one wave is trained at a consistent time interval throughout, the other waves are spawned in set intervals from each other. I prefered this over a more random style of waves, as I could steadily increase the numbers of enemies, and offer different challenges. This AI is dependant on the charge state of units, so I am able to arrange enemy formations in specific ways, and time waves carefully so units of different speeds all arrive to the players camp at the same time. I also think it makes for the best showcase of a unit type. Level 8 and 12 force players to deal with primarily swords and berserkers, while also combining in certain formations that the player might use.

WaveAI

Waves are fully customizable

Standard AI is more complicated, requiring the AI to dynamically train and position units, and eventually use magic.

Easy AI Hard AI

A much wider array of options are given for customizing enemies to simulate different decision making despite being controlled by the same logic

What I Learned

Working through this project taught me a ton of concepts and specific to designing, implementing, testing, and vector math. Here are some of my most common subjects I learned about: