Professional Documents
Culture Documents
Practical 3 2D Game Bounceshoot
Practical 3 2D Game Bounceshoot
Mobile
Mobile Game
Game Development,
Development, BTech
BTech IT
IT Sem
Sem VII
VII
Unity and C#
Part A
PRACTICAL 3
2D Game BounceShoot
Topics Learned: Android settings, C# Scripts for Touch Device, Duplicating Objects, 2D Sprites,
Circle Collider2D, RigidBody2D, Physics Material2D, Scene Management-UI-Button-OnClick
Event, Build and Run on Android Device.
Scenario: Create a 2D Game in Unity “BounceShoot” which is an Android Game. This game
should have a boundary in portrait orientation which displays bouncing colored balls. The user
has to tap on the bouncing ball to destroy it. Once all the balls are destroyed the game ends.
Allow the user to restart the game after it ends.
Steps to be followed:
Open Unity Hub and under Projects create a new Project “Game2D_BounceShoot”.
Once the Project is opened in Unity, Rename the Scene Object as “Game” and set the
Layout as either 2 by 3 or create your own layout.
Android Settings:
o Select File Menu -> Build Settings
o Select Platform as Android (If Android platform does not exists then go to Unity
Hub and Install Android SDK & NDK Tools).
o Click on Player Settings Button and under Resolution and Presentation->“Default
Orientation as Portrait”. And “Scripting Backend as ILCPP” and check on ARM64.
o In the Game View select the Aspect as 16 X 9 Portrait.
Running Game on Android Device:
o Option1: Create an .apk file by selecting File Menu -> Build Settings->Build which
can be later mailed or copied to your Android Device.
1|Page
Mobile Game Development, BTech IT Sem VII
Unity and C#
o Option2: Connect the Android Device to your Laptop/Desktop on which the
Game is created using USB port and keep Debugging Mode on the Android
Device. And select File Menu->Build Settings->Build and Run to directly run the
Game on the Device.
2|Page
Mobile Game Development, BTech IT Sem VII
Unity and C#
Part B
(to be completed by students)
(Students must submit the soft copy as per the following segments. The soft copy must be
uploaded on the Blackboard. The filename should be Batch_RollNo_Exp_No)
Roll No.: I057 Name: Siddharth Somesh
th th
Prog/Yr/Sem: MBA Tech IT/4 /7 Batch: 2
Date of Experiment: 03-08-2021 Date of Submission: 03-08-2021
1. Program: (Write Topics Learned, Scenario, Paste your program code (C# Scripts), Project
Window, Inspector Window of any one Ball object and Button).
Topics Learned: Android settings, C# Scripts for Touch Device, Duplicating Objects, 2D
Sprites, Circle Collider2D, RigidBody2D, Physics Material2D, Scene Management-UI-
Button-OnClick Event, Build and Run on Android Device.
public class Ball : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
3|Page
Mobile Game Development, BTech IT Sem VII
Unity and C#
}
void OnMouseDown()
{
Destroy(gameObject);
GameObject.Find("GameManager").GetComponent<GameManager>().ScoreUp();
}
}
public class GameManager : MonoBehaviour
{
// Start is called before the first frame update
int score=0;
public GameObject winText;
public GameObject restartButton;
public void ScoreUp()
{
score++;
if(score==4)
{
winText.SetActive(true);
restartButton.SetActive(true);
}
}
public void Restart()
{
SceneManager.LoadScene("SampleScene");
4|Page
Mobile Game Development, BTech IT Sem VII
Unity and C#
}
}
Project Window:
5|Page
Mobile Game Development, BTech IT Sem VII
Unity and C#
6|Page
Mobile Game Development, BTech IT Sem VII
Unity and C#
After Winning:
7|Page
Mobile Game Development, BTech IT Sem VII
Unity and C#
After the successful completion of the aforementioned lab, I could make the following
observations:
In order to add bounciness to the balls, Physics Material 2D must be created in
which Friction should be set to 0 and Bounciness to 1.
If Bounciness is set to a value greater than 1, the balls will bounce too fast and go
past the boundary of the viewable area in the game.
The Restart Button and WinText do not appear until all the balls have been
clicked on to destroy them.
Restart Button is set to active once the score reaches 4 and thus becomes visible
along with the WinText.
Using SceneManager, clicking on Restart Button leads to the Sample Scene being
reloaded again to restart the game.
4. Conclusion (Learning Outcomes): How were the outcomes defined for the experiment in
Part A fulfilled through the scenario (Write on each Learning Outcome)?
8|Page
Mobile Game Development, BTech IT Sem VII
Unity and C#
After the successful completion of the aforementioned lab, I could make the following
conclusions:
Understood the settings in Unity to make the game build for Android.
Understood how to find and apply the respective 2D components in this game
scenario.
Understood how to design the game in accordance with the game scenario.
Understood how to apply programming concepts to establish game dynamic of
restarting the game and getting the winning text.
9|Page