You are on page 1of 9

SVKM’s NMIMS University

Mukesh Patel School of Technology Management & Engineering

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.

Learning Outcomes of Practical: Students would be able to


1. Understand the Android and Unity Settings for Game Development.
2. Find and match the apt 2D components required as per the Game Scenario.
3. Design the look and feel of the Game as per Game Scenario.
4. Apply Game Dynamics & Programming Concepts to make the Game interactive.

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

SVKM’s NMIMS University

Mukesh Patel School of Technology Management & Engineering

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

SVKM’s NMIMS University

Mukesh Patel School of Technology Management & Engineering

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.

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.

Program Code: C# Script Ball


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

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

SVKM’s NMIMS University

Mukesh Patel School of Technology Management & Engineering

Mobile Game Development, BTech IT Sem VII

Unity and C#
    }

    void OnMouseDown() 
    {
        Destroy(gameObject);    
        GameObject.Find("GameManager").GetComponent<GameManager>().ScoreUp();
    }
}

C# Script: Game Manager


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

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

SVKM’s NMIMS University

Mukesh Patel School of Technology Management & Engineering

Mobile Game Development, BTech IT Sem VII

Unity and C#
}
}

Project Window:

Inspector Window: Ball Sprite

5|Page
Mobile Game Development, BTech IT Sem VII

SVKM’s NMIMS University

Mukesh Patel School of Technology Management & Engineering

Mobile Game Development, BTech IT Sem VII

Unity and C#

Inspector Window: Restart Button

6|Page
Mobile Game Development, BTech IT Sem VII

SVKM’s NMIMS University

Mukesh Patel School of Technology Management & Engineering

Mobile Game Development, BTech IT Sem VII

Unity and C#

2. Output: (Paste Output Screens of Game played on Android Device).


Start Screen:

After Winning:

7|Page
Mobile Game Development, BTech IT Sem VII

SVKM’s NMIMS University

Mukesh Patel School of Technology Management & Engineering

Mobile Game Development, BTech IT Sem VII

Unity and C#

3. Observations: Write about Physics Material2D and OnClick Event of UI-Button.

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

SVKM’s NMIMS University

Mukesh Patel School of Technology Management & Engineering

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

You might also like