Thesis Project - Using dynamic behaviour trees to add variation for AI in immersive sim games
For my final year project I investigated how to make AI behaviour more vaired for stealth games (Inspired by Dishonored and Thief) while keeping their actions fair and predicatable. The project was made in UE5 with C++ and consisted of a stealth focused player character, custom perception components and behaviour trees that adapt to a trait system.
The FPS stealth controller includes the following features:
- Leaning (in all 8 directions)
- You can lean with WASD and hold multiple directions at once
- If you hold two inputs in a diagonal direction you don't lean as far as if only held in one direction
- Stooping under objects when crouched (like in dishonored)
- When crouched as you move into an object with enough space for your character they will lower down to fit
- Goes to the exact height needed no lower
- You will dynamically go lower or higher as you move between cover (shown in video)
- Vaulting over objects to navigate the environment
- Step notifies, the number of steps you take changes if you're crouched, walking, running and notifies the AI perception
Guards can be assigned traits across the 4 categories of Perception, Relationship, Tenacity and Environment. These directly affect the guards behaviour with how they detect the player, perform their behaviours and react to the environment to give more variation to the AI while still allowing the player to know what they'll do through an inspection UI that lets them see the traits.
Perception traits affect the hearing and vision component, changing the scope of the two vision cones and the thresholds for audio detection. These traits can also change the detection speed for the player detection system. There are 7 perception traits in the prototype.

Relationship traits affect how the AI will react when seeing other agents in different states, for the prototype I focused on when an agent sees the body of another with there being a reaction beneficial to the player and one detrimental. A dialogue bark will also be played to let the player know that the trait has activated.
Tenacity traits traits directly affect the running of the behaviour tree, changing blackboard values and swapping out chunks of the behaviour tree such as the search routine with the pre-emptive trait that alters how an agent searches the environment. The images below show the regular search subtree followed by the pre-emptive trait subtree it gets replaced by.


Environmental traits are more of a wild card and run on a service allowing functionality to be more bespoke. The two traits I made for the prototype were being afraid of the dark and door aware. The first trait checks if the agent has been left in darkness and if so they will abandon their routine to run to the nearest lightsource, running around the level frantically if no light source is left. The second trait has the agent keep track of if doors are meant to be open or closed and if this changes when they walk past they will change it back.

There is a base behaviour tree with many of the states leading to dynamic behaviours that can be changed at runtime depending on the traits or reaction to the environment. The basic behaviour allows for patrolling, searching, and chasing the player.
