top of page

Week 4: Nicholas McInroy

  • Nicholas McInroy
  • Jan 29, 2017
  • 2 min read

Introduction

In the fourth week of final project, I implemented coroutines in several scripts, optimized AI, created a game manager, and implemented the first game mode our game has, Tug-of-Boar.

Coroutines

As some of you may know, in Unity you can use the function StartCoroutine() to, well obviously, start a coroutine. This allows processes to be threaded essentially so they can process at the same time. A neat feature about these coroutines is the ability to wait a certain amount of time or until an even happens. So instead of keeping a timer and checking it every frame in update, I can now just start a coroutine that waits the required amount of time and then does what it need to do. All the while being more efficient.


Optimization of AI

At the beginning of the week, the AI dopped our frames from 90 fps all the way to 4 - 15 fps. This clearly set off a red flag and we decided to take a look at the AI and see if there isn't something we can do about it. So, I took several actions out of update and put them on their own coroutines to reduce the amount of taxing calculations that the AI had to do like line of sight checks, to name one. Coroutines did help the AI immensely, but the optimizations I did also included precalculated some sin and cosin values at start instead of at run time.Another thing that slowed the AI down was GetComponent(). To reduce the impact of this function I stored the component at start so I would only need to call it once. Speed vs Memory will always be the balance for us programmers, software engineers, and game developers.

Game Manager

As a part of my responsibilities for the week, I was tasked to create the Game Manger. The game manager is responsible for managing respawns, team lists, teleporter locations, and team materials. This allows the game to use less memory as there only needs to be one location that has the material and teleporter information. Instead of all the AI have a copy.

Tug-of-Boar

In the game Tug-of-Boar the player is the blue team leader. The team leaders have 200 hp while regular minions have 100 hp. Each team has 1 leader and 4 minions. When a minion dies he switches teams. The goal of the game mode is to kill enemy minions so the switch to your team. Once you acquire all the minions you can take out the leader and win. It is you versus the other teams leader and the rope is the minions.


 
 
 

Comments


bottom of page