top of page

Evasion part 2

For my next step in this project I have been working on the evasion phase for my stealth game. During the evasion phase I am aiming to have the AI chase the player until they lose sight, search the immediate area around the players last known location and then resume patrols. So far I have the chasing behavior and the preliminary search sorted out. I have also been working on having multiple AI characters interacting with the player at the same time, and fixing any issues I have encountered.

Chasing update

The chasing behavior tracks the players location using a task called "Follow player" which is basically an improved version of the tracking I was using earlier in the project. Follow player runs on a simple parallel with the Chasing task and works using a line trace to the player. I used a cast to the player character as a quick check to see if the line trace has hit.

If the cast fails, then the AI has lost sight of the player and a "Last known location" ghost character is placed. I spawned the ghost character as an actor in the world and added an overlap event to set the AI character into search mode.

Search immediate area

When the "Start searching" bool is set to true, one of the branches in the combat selector will reach new event. This event is called directly in the AI controller which switches the AI behavior tree. Using separate behavior trees seemed like the best bet when dealing with combat and patrolling, as both these states are very different and having it all on the same tree would only over complicate things.

The "search immediate area" task is pretty simple but works quite well. It uses a random location in radius node to send the AI to locations close to the "Last known location". This can be easily tweaked if I need to adjust it.

Using multiple AI's

Getting my enemies to act more like a squad as has been quite challenging so far. The first adjustments I have made have been to make sure that most of my blackboard keys are not instance synced. Watching enemies run for cover when they are nowhere near the player, because they were all using the same instance of the behavior tree, was one of the crazy results of this.

I also had issues with the enemies clipping through each other, as they had nothing to make them aware of each other in my blueprints. Luckily a quick check of the unreal 4 documentation revealed that there is a built in avoidance system in the character blueprints. Sometimes what seems like a major issue can be solved by a simple tick in a box.

Finally, I am starting to build on functionality in my game mode. I have set up events to get all AI characters in the game and switching all of their behavior trees depending on the situation. It is just a case of getting everything to fire when I want it to.


Recent Posts
Archive
bottom of page