Week 5: Nicholas McInroy
- Nicholas McInroy
- Feb 5, 2017
- 2 min read
Introduction
Currently it is the end of the first week of month two. So in the fifth week of final project, I implemented a solution to the tunneling of the paint balls, worked some more on the Game Manager which includes adding a working win and loss condition to the Tug-of-Boar game mode, and finally I started to implement Object Pooling.
Tunneling
To start tackling the tunneling problem, I took a look at the DontGoThroughThing script online. As soon as I figured out how it worked, which it was familiar as I had to do this type of collision detection in Engine Development, I implemented a similar algorithm with some optimizations in my projectile script. What this algorithm does is check if the object moved more than what it is "allowed", which is just a value that represents how much it can move with out a possibility of tunneling, if it passes that threshold it will do a ray cast to check if it hit anything. If it did it moves back to the collision point.
Game Manager
The Game Manager is now a singleton. I replaced all FindObjectOfType<GameManager>() with GameManger.instance which is much more efficent and saves memory as each object doesn't need a copy f the object. The game manager also handles time expiring. The game is a draw if both teams have the same number of minons. If they do not have the same number of minions, the team with the most minions wins. If all the minions are eliminated on the enemy team and the leader is taken out then the game ends.
Object Pooling
To make the game run more efficiently, we began adding the systems for Object Pooling. Instead of deleting and instantiating dozens of projectiles and splat marks, we are going to instantiate them at start and set them to false. When we need an object it will set the object to active and use it as if it was a new object. Unity has a great tutorial on a simple object pooling method but I want to add a more robust system.
Comments