Strandead

Strandead

The third project we were tasked to create was a Top Down Shooter style game. This was the project I was most looking forward to, as Top Down Shooter games appeal to me the most, and I would like to explore them further. As with the previous projects, I had an idea of what the game would look like previous to any creation of the game.

Exploration

After watching the tutorials provided to us, I then went on and explored the further ideas I had for this project. Additionally, I included previous features from my Alien Invasion project, in which I gained valuable experience, and also created the sprites for the player, bullet and zombies. The zombies would move towards the player, and if they collide with the player then they would lose the game. Secondly, in this project I wanted to create my own background music which would intensify the gameplay. This was not too difficult, as all that was required was creating an object and adding an audio source to the object.

Strandead Interface

Challenges

For this project to work correctly, the camera was required to follow the players movement. This was my first project where the camera had to move and I undertook some additional research for this script to work. I had found a script which followed the players movement. However, the camera was not showing the player or other objects in the game view. I had later found out that the offset on the ‘Z’ axis of the camera was affecting this, and the offset was then changed so the player and objects were visible.

Another struggle with this project was the collision detection between the bullets and enemies. After multiple game tests, I was aware of a bug where the enemies could walk through or over objects which were meant to be obstacles for the enemies. With the bullets also travelling through enemies when they were meant to hit. I had changed the enemies colliders to polygon colliders from box colliders, however this did not seem to have an affect on the collision bug. My theory was that the bullet speed was too fast to detect collision between the enemies.

In this project, the script which was the most confusing for me was the Player Movement script. My reasoning is because of the Mathf.Atan2 function. This function was the most complex piece of code I had encountered so far. The function returns the angle in which the mouse is on the screen, and translates it into coordinates in which Unity understands. For future projects, this piece of code will be extremely useful for games which require the player to use the mouse.

Player Movement Script

Unity Strengths and Weaknesses

I would argue that a definite weakness of the engine is the collision system as mentioned above. As I have experienced first hand, colliders on objects or enemies will not always work 100% of the time. As the detection would depend on how fast an object is travelling through the collision box. For example, a bullet travelling fast would not always collide with the collision box, and this would create visible bugs and possibly annoy the player.

Conversely, a strength of the engine is that it has a long list of built in functions which are very helpful for projects. For example, in this project I wanted to have the bullets prefabs to be deleted after a certain number of seconds. Since I had noticed that if the fire button was repeatedly pressed then there would be a vast number of bullets on the screen. This would make the game lag, so I used the ‘TimeToLive’ function, which would prevent the game from lagging and delete bullets after a number of seconds.

Additional Research

As mentioned above, I had researched how to make the camera follow the player wherever they move. I had found a helpful answer on a Unity discussion board which provided the piece of code I needed (Jack-Howard, 2015).

References

Jack-Howard (2015) How to get camera to follow player 2d. Unity Answers. 18 January. Available online: https://answers.unity.com/questions/878913/how-to-get-camera-to-follow-player-2d.html [Accessed 8/11/2021].

Please click the link to play Strandead – https://nathan1230.itch.io/strandead