top of page
  • Writer's pictureCallum Winfield

Devlog 6 - Enemy AI and Behaviour Trees

Before working on the new Ai system for the enemies in the game, I wanted to look into how Behaviour Trees are structured in other games such as in Halo 2 released in 2004 which came up with the initial system. Behaviour trees define the actions of Ai characters by the actions of the or the state of the game world.


As Halo 2 is primarily a FPS, the Ai act in a more agressive way and revolve them selfs around find cover, shooting the player and flanking. As the Wayfinder Ai is more dominant in the game world and will actively have an advantage over the player, it is important to structure their behaviour tree in a different manor.

Below is a GDC talk from 2004 from Damian Isla who was a lead design on the Ai in Halo 2, I refered to this before starting the Ai in The Wayfinder.

Behavioiur Trees In The Wayfinder

Unreal engine has a very vast behaviour tree system already implemented into it, so when looking into tackling the ai in the game there was already alot of established systems in play which I looked into when working on the Ai Companion. Below you can see one of the intial test of applying a behaviour tree that gave free movement to the Ai enemy, allowing it to pick points at random in the world and go to them. Though there was many bugs around the animations and movements speed at this stage.

To achieve even a two state behaviour tree there is alot of components that are needed, below you can see all components that are used to get this Ai to work.

This is the current behaviour tree for the ai, the tree start with the base root node which just signifies the start of the tree. This then leads into the Selector node which runs through all possible options moving down the tree one at time checking if the Ai can do any of them. The first node the Sequencer checks is if the Ai cant see the player it will find a random location in a local radius of the actor, the next node is a simple one which just tells the ai to move to that location it has determined. The last node on that branch is just another simple one which makes the ai wait at that point its just found for a set amount of time that can be customised on the fly.


The next branch it runs down is if it can see the player. If the ai can it will run a short cool down before running further branches this is to give the Ai the effect of it realising its just seen an enemy. Once this is done it will begin to chase the player. This goes into the first sub node which is find the player's location, this is simply the Ai computing where it has just seen the player and then leading into the final branch which is a simple command to chase the player.

Some of nodes you can see on the behaviour tree above are already built and coded into unreal engine, such as the nodes like wait and selector which have all functions set up. Though the other nodes I had to set up myself, such as "Find Random Location" and "Find Player Location".

Above you can see the node set up for the Ai finding the players locaion and storing that data to use when heading to the that location.

The blueprint above is found the main Actor asset for the Enemy Ai, this basically just tells the ai when finding the players location it cast to the one player character in the scene.

The final node set up you can see is from the Ai's command to find a random location in the world and head to that point relative to the actors location.

This was the first attempt at the enemy ai, in this set up the enemy would spot the player and head to that location it initially saw the player. Though this method made the Ai seem very unatural in how it handles chasing the player.

This was the second attempt where the Enemy ai would follow the player instead of head to its location, the only issue with this version is the enemy would stutter around when right behind the player as it wouldnt stay at a certain distance away from the player and would instead run to collide.

This is the final set up with the Ai staying at a certain distance from the player when running. The game play above was captured from a quick play test in which a class mate tested out how the Enemy AI reacted to different movement styles in the demo map.

19 views0 comments

Recent Posts

See All
bottom of page