This is my submission for Assignment 1 for KIT109

Pong was created with just blank sprites, Physics objects and scripts. 

I used 2 audio files from:

https://freesound.org/people/NoiseCollector/sounds/4388/

https://freesound.org/people/NoiseCollector/sounds/4390/

Lots of the scripts were modified or original from the tutorials and nearly all the modifications or new scripts were based off the docs from:

https://docs.unity3d.com/ScriptReference/

I decided to use the Physics based approach for my base pong game as that was quite an easy way to get it to start and get it working. I made 5 collider objects (The two paddles, the ball and the two upper walls) and two triggers that are off screen (The side walls). I made the 2 triggers add to the score when anything with the tag "Ball" Passed through them. The Paddles had modified Movement scripts that just changed their y co-ordinate value and the ball had start moving in a random direction and a "destroy ball" (Its a bad name because it doesnt actually destroy the ball) scripts.


I also attempted all of the further exercises.

The resetting the ball to centre and starting again was done with the "Destroy ball" script that resets the coordinates, rotation, velocity and angular velocity to either zero or their original value and calls randomDirection from the Start moving in random direction script. 

To stop the paddles from leaving the scene I added if statements in the movement script on each player that checked that their location wasnt out of the bounds of the area and if it was it reset it to the boundary of the game. Not super elegant I probably could have made the paddle collide with the outside wall to stop it but it worked.

I added score like the high score scene in tut 4 by creating a ui element and having a script change the value of said ui element. 

I Added endGameListener to look for if each player had reached the desired score. The script then called the appropriate end game screen depending on who won and what mode you were in. This definitely is a sloppy way of doing it and make it quite annoying to set up which one went where. I could have made the end game screen get what player won from the endGameListener in the pong scene and what game mode they were just in and changed what loads on a play again button press.

To create the AI for the second player in 1 player mode I made a script that checked what the balls y co-ordinate was every update and then calls Vector2.MoveTowards with the new y position with checks to see if they were off the screen like the player movement script.

I did sound 2 ways , The paddles got a playSound Script that checked for a OnCollisionEnter2D call and then called the audio Source component and the point sound just had a call to the audio source after the score++ call in PlayerCollectScore.

To Increase the Ball speed I created a new physics material for the ball with 0 friction and 1.1 bounciness so it increased each bounce.



Leave a comment

Log in with itch.io to leave a comment.