top of page
  • Writer's pictureCharlie Kowalski

Ai Companion Project

Updated: Feb 27, 2022

I decided for the last three weeks to work on a personal project that will derive from a previous system I worked on, a companion for the player driven by behavior trees. I had a few goals for this project

  • I wanted to focus on the behavior trees specifically in Unreal Engine, I wanted to put more hours into working with Unreal.

  • Combat was a huge focus for the Ai, I wanted the Ai to feel helpful and assist the player on defeating enemy's.

  • Animations for the Ai and player should be smooth and blend together.

Week 1:

The beginning of the project was rebuilding what I've already accomplished in the past and refamiliarizing myself with the systems of Unreal. I arranged the system to operate around the number keys using them to control the companions behaviors. I implemented them as so

  1. Wait

  2. Follow Player

  3. Move To Target

Wait and Follow where simple to implement because Unreal has premade tasks for there behavior trees, allowing me to add the behavior's without creating my own. Move To Location proved a bigger challenge as I wanted a UI element so the player could have more control of where they placed the companion. The difficulty with this element was making sure the player couldn't position the companion outside of the reachable navigational area (Navmesh).

Week 2:

This week was my step into the world of animations and system building and a majority was spend on research as I am usually the tech-first, make pretty later programmer. I first targeted giving my players and companions weapons by downloading a free weapon pack from the unreal store and adding sockets to the skeletons of both characters.

After that I built the damage variables for the weapons and formed trigger boxes around the damaging parts of the weapons. To make sure the weapons didn't damage multiple times during the attack animation, the trigger boxes are only activated during certain portions of the animations.

Then it all came to a ahead with the blending of the animations I made sure to cache the default skeleton of the character. Then from there I applied the animations to the upper body of the skeleton and blended that modified upper half with the original walking/running/falling animation of the legs.

Week 3:

For this final week, I combined my research from the previous week and worked on animating the companions attack and the logic for finding a enemy and attacking them. This is accomplished by labeling my enemy's with a enemy tag and having the Ai choose a random enemy to then attack. I used the same process of animation I used on the main character to give the companion its own dagger animations and the enemy reactions for being hit and killed.

4. Move Towards Enemy and Attack

The logic for this behavior is achieved using a parallel selector, it runs two tasks in parallel and ends only when both nodes of the tree are ran. Since we needed to make sure not to fire the second task until the enemy's was in range, we used a blackboard decorator to only fire when the enemy was found to be close enough to strike.

And that's it! We are done! This we super exciting to work on and scoped perfectly for a 2-3 week project. I'm excited to work on a project like this again and check out the video below to see a small demo of the project in its entirety!

8 views0 comments

Recent Posts

See All

Define your final game: game description, intended player experience, platform, technology, market, team members. What changed from the mid-mortem? Set the context for the rest of your reflection. Ach

Hello and welcome to my third development blog! It has been a while since I've posted one due to being swamped with capstone work and work for other majors but I am here to talk about my experiences!

bottom of page