You are on page 1of 20

NITTE MEENAKSHI INSTITUTE OF TECHNOLOGY

(AN AUTONOMOUS INSTITUTION, AFFILIATED TO VISVESVARAYA TECHNOLOGICAL UNIVERSITY,


BELGAUM, APPROVED BY AICTE & GOVT.OF KARNATAKA

COMPUTER GRAPHICS

Learning Aactivity-2
Aactivity COMPONENT
On

Roller Ball Game


Submitted in the partial fulfilment of the completion of 6th semesterComputer
Computer Graphics during the
academic year
2019-20
Bachelor of Engineering
In
Computer Science and Engineering
Submitted by:
JEEVAN J ACHARYA 1NT17CS072
K R GURUVYAS 1NT17CS078
PRANAV P PATIL 1NT17CS127
PUNNYA K A 1NT17CS137
Department of Computer Science and Engineering
Nitte Meenakshi Institute of Technology
(AN AUTONOMOUS INSTITUTION AFFILIATED TO VISVESVARAYA TECHNOLOGICAL UNIVERSITY, BELGAUM)
PB No. 6429, Yelahanka, Bangalore 560-064,
560 Karnataka
Telephone: 080- 22167800, 22167860
Fax: 080 – 22167805

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

CERTIFICATE

This is to certify that the Unity 5 project titled “ROLLER BALL GAME” is an authentic
work carried out by JEEVAN J ACHARYA (1NT17CS072), K.R.GURUVYAS
(1NT17CS078) PRANAV P PATIL (1NT17CS127) and PUNNYA K A (1NT17CS137)
(1NT17CS137
bonafide students of Nitte Meenakshi Institute of Technology
Technology,, Bangalore in partial
fulfilment for the course “Computer
Computer Graphics
Graphics”, to award the degree of Bachelor of
Engineering in COMPUTER SCIENCE AND ENGINEERING of Visvesvaraya
Technological University, Belagavi during the ac
academic year 2019-2020.

Signature of the Faculty In charge Signature of the HOD

Mrs. P Ushashree (Dr. M N Thippeswamy)

__________________________
DECLARATION

I hereby declare that

(i) This Presentation does not contain text, graphics or tables copied and pasted from the
Internet, unless specifically acknowledged, and the source being detailed in the report and
in the References sections.
(ii) All corrections and suggestions indicated during the internal presentation have been
incorporated in the report.
(iii) Content of the report has been checked for the plagiarism requirement

Name: Jeevan J Acharya USN: 1NT17CS072 Signature:

Name: K.R.Guruvyas USN: 1NT17CS078 Signature:

Name: Pranav P Patil USN: 1NT17CS127 Signature:

Name: Punnya K A USN: 1NT17CS137 Signature:

Date: 10-04-2020
ACKNOWLEDGEMENT

The satisfaction and euphoria that accompany the successful completion of any task would
be incomplete without the mention of the people who made it possible, whose constant
guidance and encouragement crowned our effort with success. I express my sincere
gratitude to our Principal Dr H. C. Nagaraj, Nitte Meenakshi Institute of Technology for
providing facilities.
We wish to thank our HOD, Dr Thippeswamy M.N. for the excellent environment created
for further educational growth in our department. We also thank him for the invaluable
guidance provided which has helped in the creation of a better project.
I hereby like to thank our guideMrs. P Usha ShreeDepartment of Computer Science &
Engineering on their periodic inspection, time to time evaluation of the project and help to
bring the project to the present form.

NAME USN SIGNATURE


JEEVAN J ACHARYA 1NT17CS072
K R GURUVYAS 1NT17CS078
PRANAV P PATIL 1NT17CS127
PUNNYA K A 1NT17CS137

Date: 10-04-2020
ABSTRACT

Serious video games applied for learning purposes play a significant and
important role for the modern technology enhanced education. The report
presents an educational 3D ball roller video game. The game was automatically
generated by means of declarative description by an open software tool
named Unity game platform.
The ball roller game here includes a ball being rolled in the game field and its
task involves collecting the cubes and scores a point for each one collected. In
this project we have implemented14 boxes and the ball is operated by the user
using direction keys from the keyboard. When the player is successful in
collecting all the boxes he wins the game.
TABLE OF CONTENTS

Sl. No. Topic Page No.


1 INTRODUCTION 1
2 INTRODUCTION TO UNITY 2
3 REQUIREMENT SPECIFICATION 4
4 IMPLEMENTATION 5
5 SNAPSHOTS 11

6 CONCLUSION 13
7 REFERENCES 14
1. INTRODUCTION

Unity is a cross-platform game engine developed by Unity Technologies. The


engine is used to create three-dimensional, two-dimensional, virtual reality,
and augmented reality games, as well as simulations and other experiences.

This project being developed using the above game engine is named as the
Roller Ball Game in which a spherical ball being the main game object attempts
to collect other random special game objects.
This involves creating the game objects along with their components, setting
the values on their properties and positioning them on the scene to create the
game. A player controls the ball around the game board and the ball is moved
using physics forces. The input from the player is accepted through the
keyboard and this input is used to apply forces to the ball to make it move in
the scene. The contact between the ball and the pickup game object is
detected and this event is used to pick up that particular game object. The
game counts the number of special objects collected and ends the game when
all of the game objects have successfully been collected.

1
2. INTRODUCTION TO UNITY

Unity is an engine for creating games on multiple platforms. Unity was


released by Unity Technologies in 2005. The focus of Unity lies in the
development of both 3D and 2D games and interactive content. Unity
supports 27 different target platforms for deploying. The most popular
platforms are Android, PC, and IOS systems.

1. Unity is an integrated platform that is used as a gaming engine and


framework.
2. Unity helps in develop once and publish everywhere strategy.
3. Although unity is considered to be more appropriate for creating 3D
games, it is equally used to develop 2D games.
4. In Unity, it is possible to develop games with heavy assets without
depending on the additional frameworks or engines. It enhances the
experience of users.
5. With the help of Unity, game developers have access to a wealth of
resources like intuitive tools, ready-made assets, clear documentation,
online community, etc. free of cost for creating exciting 3D contents in
the games.
6. Asset tracking and rendering, scripting are some of the features of Unity
game development that is used in reducing time and cost.

Factors that Enhances the Efficiency of Unity


1. Unity Multiplayer: Multiplayer experience in unity is unparalleled. Unity
enables the users to play for the traffic that uses the relay servers and
matchmakers.

2. IDE: Unity provides a text editor to write the code. To reduce confusion,
sometimes, a distinct code editor is also used by developers. As the IDE
(Integrated development editor) of the unity engine supports C# and
Unity Script (JavaScript), it is used in the game development process for
creating immersive and exciting games.

3. Platform Support: The Unity engine is highly acceptable due to its ability
to support a total of 27 different platforms. It is used for developing and
deploying gaming apps that can be easily shared among personal
computers, mobile, and web platforms.

2
4. Debugging: Debugging and Tweaking is extremely easier with Unity
game development. During the game play, the game variables are
displayed, and it allows the developers to debug the process at run-time.

5. Unity Analytics: The built-in analytics of Unity offers indispensable


insights regarding the game. It is necessary during the release of a game.
Information related to the distribution of the game and feedback of the
players is obtained through unity analytics.

6. Graphics: The unity engine provides high-quality visual effects and audio.
The visuals developed by Unity are adaptable on every device and
screen without any compromise or distortion with the quality of the
images.

Unity is the most preferred gaming engine. On Unity, the coding part of the
game development process is only about 20%. Hence there is reduction in the
requirement of extensive programming skills.

The free license offered by Unity makes it open for game developers all over
the world. The developers are allowed to access the resources from the asset
store of Unity, which is used to enrich the process of mobile game
development.

3
3. REQUIREMENT SPECIFICATION

Unity editor system requirements


Minimum System Requirements to run the Unity Editor.

Operating system Windows 7 (SP1+) and Windows 10, 64-bit versions


version only.
CPU X64 architecture with SSE2 instruction set support
Graphics API DX10, DX11, and DX12-capable GPUs
Additional Hardware vendor officially supported drivers
requirements

Unity Player system requirements


Minimum System Requirements to build and run the Unity Player.

Operating system Windows 7 (SP1+) and Windows 10


version
CPU x86, x64 architecture with SSE2 instruction set
support.
Graphics API DX10, DX11, DX12 capable.
Additional Hardware vendor officially supported drivers.
requirements

4
4. IMPLEMENTATION

1. Setting up the Game


Step1: Setting up the game initially involves the creation of a new
project. It creates an initial scene in the screen.

Step2: Saving the scene and providing it with a name.

Step3: Creation of a game board or the play field with the help of Unity
plane.

Step4: Creation of the player object which is a unity sphere.

Step5: Addition of colour to the background.

2. Moving the player game object

Step1: Attachment of the Rigid Body component to the player game


object.

Step2: Creation of a folder in the project to hold the C# script file.

Step3: Attachment of a C# script to employ the movement of the


player game object when an input is received from the player
through the keyboard.

C# Script

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class PlayerController : MonoBehaviour {


public float speed;
public Text countText;
public Text winText;
priate Rigidbody rb;
private int count;

5
void Start ()
{
rb = GetComponent<Rigidbody>();
count = 0;
SetCountText();
winText.text=””;
}

void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis (“Horizontal”);
float moveVertical = Input.GetAxis (“Vertical”);

Vector3 movement = new Vector3 (moveHorizontal, 0.0f,


moveVertical);

rb.AddForce (movement * speed);

void OnTriggerEnterc(Collider other) {

if (other.gameobject.CompareTag(“Pick Up”)) {

other.gameObject.SetActive (false);

count = count + 1;

SetCountText(); }

Void SetCountText () {

countText.text = “Count: “ + count.Tostring ();

if (count >= 12) {

winText.text = “You Win!”; }

}
6
3. Moving the camera

Step 1: It includes tying the camera to the player game object by first
setting the position of the camera.

Step 2: It involves the associating the camera with player game object
with a script.

C# Script

using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {

public GameObject player;


private Vector3 offset;

void Start () {
offset = transform.position – player.transform.position;
}
Void LateUpdate () {
Transform.position = player.transform.position + offset;
}

Step 3: Creation of reference for the player game object.

7
4. Setting up the Play Area

Step 1: Placement walls around the edges to keep the player game
object from falling off.

Step 2: Creation of a set of collectable objects for the player to


pickup.

Step 3: The collectable objects being cube shaped structures, they are
associated with movement to grab the player’s attention over it.
To employ the movement of the objects, they are associated with a
script.

C# Script

using UnityEngine;
using System.Collections;

public class Rotator : MonoBehaviour {

void Update ()
{
Transform.Rotate (new Vector3 (15, 30, 45) *
Time.deltaTime);
}
}

Step 4: This step involves making the pickup objects into a prefab.
This helps in making changes to a single instance in the scene.

Step 5: Creation of a game object to hold all the collectable game


objects.

Step 6: Attachment of colour to the game objects.

8
5. Counting points

Step 1: It includes setting up a tag value to pick up object.

Step2: To enable the collection of the game objects, they are


assigned with the trigger collider component.

Step 3: Addition of rigid body component to the game objects, this


move the cubes from being static colliders to being dynamic colliders.

Step 4: The above step results in the falling of the game objects due
to gravity, to overcome this; the ‘use gravity’ component is disabled.
By doing this even though the cubes don’t respond to gravity, they
would still respond to physics forces.
Alternatively, the ‘use gravity’ and ‘is kinematic’ may be enabled, by
doing this the Rigid body component is set to be kinematic rigid body.
A kinematic rigid body doesn’t react to physics forces and it can be
animated and moved by its transform.

6. Displaying score and text

Step 1: A tool is added to the PlayerController script to store the


value of the counted collectables.

Step 2: To display a text when the game is over, the Unity’s UI tool
set is used.
Firstly a new UI test element is created from the hierarchy’s create
menu followed by changing the colour of the text and addition of
placeholder text.
To display the text at the upper-left corner when the game is being
played, it is anchored to the upper-left corner of the canvas.

Step 3: This involves association of a reference to the countText by


dragging and dropping the countText game object into the slot.

9
Step 4: To display a message when all the cubes are collected another
text element is created and it is provided with the necessary
customizations and a function is associated with the text element in
the PlayerController script to display the text only when all the game
objects are collected.

7. Building the Game

Step 1: First the scene is to be saved.

Step 2: In this step the build settings window is opened, it shows the
build options for the currently selected platform.
Next the scenes are to be added to the build window, it can either be
done by the Add Current button or by dragging and dropping.
Finally the added scenes are built using the Build button.

Step 3: The game is run by executing the exe file generated during
the above step.

10
5. SNAPSHOTS

Fig 5.1: Launching the game.

Fig 5.2: Initial view of the scene soon after the game is launched.

11
Fig 5.3: It represents the scene while the game is being played.

Fig 5.4: It represents the scene after the game is successfully completed.

12
6. CONCLUSION

The Unity 3D game engine provides us with an incredibly powerful and


versatile tool for project development. It possesses striking array of
outstanding features like the visual editor, full and robust scripting, multi
platform build support and many more. Unity’s simple interface, a
friendly development environment and cross platform
framework support, all contribute to its prolonged success in the
industry.

This project developed called the Roller-Ball Game using the above
described game engine is an intelligible user-friendly game involving the
collection of cube shaped game objects with the help of a spherical
player object which is equipped with physics forces and hence moves in
response to the keyboard input provided by the physical player.
The player is indicated with the number of game objects picked up and
each time one is picked and the player is indicates as a winner once all
the game objects are successfully collected.

The above game developed helped us in understanding the various


components, features and capabilities of the Unity game engine,
including the ways in which a game can be made attractive to the users.
It motivated us in improving our knowledge regarding C# scripting and
the process of building the developed game, so that it can be
downloaded and played by the users on their respective platforms.

13
7. REFERENCES
[1]. https://www.youtube.com/watch?reload=9&v=W_fAidYRGzs

[2]. https://www.youtube.com/watch?v=7C7WWxUxPZE

[3]. https://www.youtube.com/watch?v=Xcm5H2J95iI

[4]. https://www.youtube.com/watch?v=dahT0wRVO1Q

[5]. https://www.youtube.com/watch?v=HlDGSStxuHI

[6]. https://www.youtube.com/watch?v=XtR29MmzuT0

[7]. https://www.youtube.com/watch?v=bFSLI2cmYYo

[8]. https://www.youtube.com/watch?v=hSg3e1M3hKY

[9]. https://www.capitalnumbers.com/blog/why-unity3d-popular/

14

You might also like