ButtonRealms

A VR strategy game based on the RFP of our client, Nefarious Games, where the team of 30 students was tasked with creating vertical and horizontal slices. The game started out as a clash of clans-like city-building game where the player would be able to closely spectate their citizens and direct their units in battle as a general. And the game evolved into something very different. Instead of a clash of clans kind of game it evolved into a town defence game. The player can direct the citizens to build buildings and collect resources while the town is under waves of attacks. Buildings can be used to defend the town and the player can use his surroundings to defend the town against its attackers.


  • Role: AI/Gameplay Programmer
  • Team Size: 26
  • Platforms: Vive
  • Engine: Unreal Engine 4
  • 2016-2017

I was a AI and gameplay programmer and was responsible for the combat which includes the AI of the enemies and the defences. The defences include defensive towers and traps which assist the player into defending the town. The enemies were divided into 3 classes: soldier, ranged and mages. Soldiers were simple enemies with a sword and high health. Ranged had a ranged attack and low health. Mages have a slow ranged attack but are constantly generating a spherical shield which protects everyone inside against ranged attacks from towers. My task was to make the AI look like they were attacking in a coordinated way. I developed a group based behaviour using Unreal’s behaviour trees. The group has a behaviour tree that makes the low level choices like to attack a building and give all the soldier the order to attack that building. The soldiers get an attack behaviour tree based on that class. The group stays together but the behaviour of each agent is a bit different based on their class. This way groups of agents of multiple classes are moving across the battlefield which looks like a coordinated attack by dividing goals across groups.


A VR game isn’t a VR game if it isn’t interactable so I made a interface which allowed objects to be interacted with when the player tried to pick them up or open a menu. When a vive controller touched an object it checked if it had that interface. If not then it would handle that object as a physics objects. If the object has that interface, the player can pick it up and open a menu of that object. The content of the menu are stored inside the overridden interface functions inside that object. This made distinction between objects that can be picked up and can’t be picked up fairly easy. The reason I created a interface instead of a baseclass was because we didn’t want some objects to share baseclasses.




Implementation Layered BehaviourTree


The formation has a Behaviour tree which decides what action the agents need to take. If the behaviour tree decided that the formation should walk somewhere, every agent get’s the command to walk, if it decides that the formation should attack something they get the attack command. Every command gives each agent a individual behaviour tree based on their class which controls the high level decisions of the agent. The following image shows a function that the Formation Behaviour tree calls when it commands to attack something. It forwards the command to all the agents.



The function Attack in the base class of a soldier is called which gets the attack blueprint from the parameter which is set in the inherited class and runs that behaviour tree.


If for example the class of the agent is a soldier then the attack behaviour of soldier is loaded. This behaviour tree is really simple: move towards the target and when close enough attack it.