top of page

Entity

About

Entity is a small adventure game, where you play a girl trapped at school and your goal is to get through all the rooms and to do that you need to find all the keys and avoid monsters lurking in the dark

Project Info

  • Role: AI and Gameplay Programmer

  • Time: 4 weeks

  • Team Size: 5

  • Engine: Unity

  • Engine Experience: 2 months

  • Programming Experience: 2 months

Background

Entity was a project made for Södertörn University's assignment. The assignment was to make a pac-man game. We were required to have multiple types of AI behaviours.

 

At that time I was studying design, but in my team I took over with majority of programming while leaving design to my partner designer. It was one of my first experiences working in Unity and programming in general. I got interested in programming during this project and this was my first time implementing Artificial Intelligence. 

Grid & Breadth-First-Search

Grid

The grid is generated upon the game start with specified size. 

​

The grid had to be located only on positive coordinates. To minigate the risk of my teamates accidentatly putting tiles on the wrong places I made tiles display their current coordinates.

Breadth-first search

Background

My first time writing a pathfinding algorithm, I had heard about A*, but I felt that Breadth-first search was easier to understand and implement at that time and fitted better for pac-man like game.

Challenges

The biggest challenge for me was to debug the logic. I didn't know at that time about breakpoints or gizmos. However, I found a way to see how my pathfinding was working by changing the colors of the tile cooridnates​. However I could only work on one Entity at a time.

  • Blue- found path.

  • Red - Blocked node

  • Yellow - Searched Tile

  • White - Not Searched

Algorithm

  1. Take the current position.

  2. Add to the queue and dictionary.

  3. Pick a node from the queue.

  4. Check all the neighbours of the picked Node.

  5. To find neighbours add to/subtract from "1".

  6. Check if dictionary contains the node

  7. Add to the queue and the dictonary newly discovered nodes.

  8. Repeat from the third step until found destination.

Enemies

In the game there are monsters that are preventing from achieving your goals. 

There are 4 types of enemies: Ghost, Runner, Glower and Hound.

Ghost and Runner utilize two behaviours. They wander around the map and chase the player upon spotting them. The difference between the two is that Runner's speed is increased when he's chasing the player.

Glower also chases the player, but unlike other enemies, he doesn't wander around the map, instead he's waiting at certain spots like a trap

Hound is the only enemy that doesn't chase the player, it wanders around the map and when it sees the player it informs Ghost and Runner of the player's location

Behaviours

The game has multiple behaviours that switch depending on the situation.

​

  • Wander - Picks random coordinates from a list and heads there.

  • Chase - Upon seeing the player, tries to reach the last position that the player was spotted. If a player is out of visibility, the behaviour will finish upon reaching the last seen position.

  • Hound Alarm - Hound's ability to inform others about player's location.

  • GlowerLurk - It waits until player gets close and then switches to Chase.

Player Movement

I  programmed the player movement. Our whole game is based on a grid, thus the player movement has to accomadate for that. I used Coroutines to change between tiles, by lerping the current position and desired position.

bottom of page