I have made some headway with my Pong and Breakout game.
I have used tutorials to set up a basic game in Unity which resembles Pong and I have also written some scripts. While I would not be adept enough to write a C# script from scratch in a way that executes the desired behaviours, I at least feel confident enough to read the script and understand what its doing.
I also learnt that a lot of the mechanics of my game do not need to be set up exclusively through scripting but can be established in the Inspector through Unity and through the creating of ‘Components’.
Here is my progress so far…
I largely used this tutorial as a guide to help me set up the first part of the game (Noobtuts.com. n.d.). As I am creating something inspired by Pong but that is not actually Pong, once I had the mechanics in place, I made alterations to my game, such as adding two balls rather than one and having the balls spawn closer to the paddles. Through this tutorial, I learn about several components, which include Rigidbodys, Collisions and Physics textures.
The BoxCollider component is what is used to ensure that the balls make contact with the paddles, but also the sides of the walls.
The RigidBody component is used not only to add gravity but also to control or reduce the gravity. This is what allows the paddles to move up and down and also for the balls to bounce back and forth.
A physics texture is what is applied to the ball, which allows it to bounce between the paddles and the sides of the walls. The bounciness is crucial to ensure the ball does not fall out of play or slide off the paddles… otherwise, we would not have a game here.
I wrote two scripts for this game. One for the control of the paddles, which will be operated by the players. At present, this game has been set up so that the left paddle is controlled by the W and S key, whereas the right is operated by the up and down key. Ultimately, I only want one of these paddles to be controllable by the player; the other I want to be controlled by an AI.
The second script was to control both balls. This script would control the speed that the balls move at, as well as the functionality to configure the speed within Unity. The script also allowed me to determine the speed and the direction of the ball depending on what corner of the paddle it hit, much as it does in Pong itself.
I was initially going to create to separate scripts for both balls as they both move in opposite directions, but I realised it would be more efficient to have one script for both balls and that I could determine their initial movement by configuring the speed. As the ball moves to the right by default, as determined in the script, the left ball was set to a speed of 30, whereas the right ball is set to a speed of -30.
While I am relying on tutorials quite heavily to put this game together, I am ensuring that I think critically while building my game. While tutorials are a great resource for learning, I will always need to think critically when I am using them and it is important to know why certain things are done in the way they are and not just how.
When I use tutorials, I will never follow them to the absolute letter but I will deviate from them from time to time in order to gain an understanding of how something works. This is important for my personal development, as if I just follow something step-by-step, I would not actually be learning, but simply copying what others have done.
This is the approach I am using here. I am relying on tutorials, but I am thinking critically while I am doing so. I am also going to use a range of tutorials on different aspects of Unity to realise this game, so that I am not just relying on one source and one approach alone to game development.
Noobtuts.com. n.d. noobtuts – Unity 2D Pong Game. [online] Available at: <https://noobtuts.com/unity/2d-pong-game> [Accessed 8 February 2021].