First, I started by making the character out of unity’s 3D object (cube, sphere, etc.) Then I made a simple movement script to move the player in all directions. Next, I created a ball and updated the script so the player holds the ball when inside a specified radius. If the player is holding the ball, it will trigger an animation to dribble the ball. When the user holds space, it will rotate the player towards the hoop, and hold the ball over their head. If the user releases space, a separate script will be called, which sends the ball on the correct trajectory to hit the hoop. Next, I added a script to the target to make it move side to side and increase its speed each consecutive throw.
Next, I added to invisible colliders on either side of the hoop. If the player throws the ball, and picks it up again without the colliders being triggered then the player will get a point. If the colliders have been triggered before the player picks up the ball, their score is reset to zero.
Then I added a crowd made from the same player model. I added animations to make them jump and swing their arms at random speeds to add variation. They also have a script to rotate them very slowly at different intervals. Finally, I added random colored clothing for each fan to further increase variation.
Lastly, I added a field to enter the users name which is displayed on the back of the player’s jersey. That name is also stored in a database with their score and the top 5 high scores are shown in the top right. I used php and MySQL to create the database and access it from unity. At the end of the project, I attempted to build it to android but ran into a gradle error that I couldn’t figure out.
Play the game from this link:
https://ects-computerprogramming.com/StudentWork/MMelaragno/basketball/
