"Your death was unfair and unjust this is a chance for you to get back to the world of the living, one of the damned souls have been given a chance to escape their fate in Hell. If they should catch you then you will be brought to me and they shall be released back into the world. 

To escape find all items that belong to the soul and get to the door. You have a flashlight and there are batteries around the place, find them and you can slow the soul down.

I wish you luck."

Mechanics

pic1.png

Figure 1

An image of the generated maze’s node grid, shown using gizmos, where the red nodes represent the unwalkable areas.

pic2.png

Figure 2:

The main algorithm pseudocode for the A* algorithm [2].

pic3.png

Figure 3:

The generated path from AI to player, showing the nodes and the angle of movement

Procedural Generation

The game’s procedural generation was created using a tutorial from Catlike Coding [1]. The maze is generated before the artificial intelligence (AI) components are generated. The generator places the walls, floor, doors and items in the game.

 

A* Pathfinding

Initially the game used the NavMesh component to do the pathfinding to the player, but the component would not work. The other way to make the AI get to the player was by making an A* pathfinding algorithm.

I used a set of video tutorials made by Sebastian Lague [2] which helped to develop the correct algorithm.

When the game is loaded, the maze is first procedurally generated before the pathfinder system begin.

Nodes

First it creates a grid of nodes from the maze that is created. The nodes have a radius of 0.1 units each. The nodes each have a mask to show if the area is walkable or not.  Each walkable node is also giving a value to show what parts of the floor are more walkable to give priority to certain nodes when the AI creates the path.

Algorithm Implementation

After the node grid has been created the AI finds a path through the grid to the target which is the player in this game. The algorithm begins going through the nodes beginning from its position and travels through the neighbouring nodes but chooses which ones by the cost of going to them. The algorithm in Figure 2 shows how each of the nodes are compared to until the path of lowest cost is formed to the target node.

Play Testing

The algorithm has a path smoothing algorithm within the code which allows the AI to walk through walls, this adds to the ghostly effect of the predator.

The path updates each time the AI gets to the end of the first path created or until the AI encounters and sees the player. This path is also updated each time the player collects an objective in the game as well as when the final door is opened.

The player is told that the AI has found their position by the banshee scream made in the game which also shows which direction the predator is coming from through the 3D sound movements.

After the player has collected all the objectives another path is requested by the pathfinder, creating a path to the final door for the player which is indicated by a floating ball for the player to find and follow.

REFERENCES

[1]  Flick, J., 2019. Maze, a Unity C# Tutorial. Catlikecoding.com.

[2] Lague, S., 2019. A* Pathfinding Tutorial (Unity) - YouTube. YouTube.

Previous
Previous

Alien Escape

Next
Next

Astr0-60