SlideShare a Scribd company logo
Lecture 4: Shoot Basketball
Game #2
Dr. Kobkrit Viriyayudhakorn

iApp Technology Limited

kobkrit@iapp.co.th
ITS488 (Digital Content Creation with Unity - Game and VR Programming)
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Download the Starting code
• Go to https://github.com/
kobkrit/VR_basketball_lecture_3
to download the starting code.

• Unzip the project.

• Open Unity.

• Open the project by selecting
the unzipped folder.
Object Collider
Click at a Ground Game Object. Uncheck the Sphere Collider and Press "Run" to see the effect.
Collision
• We can check the collision
between objects in Unity very
easy.

• To demonstrate, We will create a
mini shooter game which use a
cube as a target.

• If user shoot a ball that hit the
target, user get a score.
Collision: Adding Target
1. Right click to create cube as the target.
2. Move the target to the center of the field. 

Make it see within camera.
Collision: Counting Score
3. Change the name of the cube in the inspector,

as "Target"
4. Add the C# Script 5. Name it as "Score Count" and
Make it associated with the "Target".
Collision: OnCollsionEnter Method
6. Adding the OnCollisionEnter method. 7. Run
Exercise 1
• Modify the ScoreCount.cs code
to be able to count the score.

• When a ball hit the target, the
score increases by 1.

• Print out the score by

print() command.
Add multiple targets
• To complete the game, we are
going to have multiple targets,
as we have designed to have
multiple basketball’s
backboards

• We will cloning the target into
2-3 targets.

• Move the newly cloned target
to different locations.
Duplicate the target
1. Select the target, right click,

select "Duplicate".
2. Move the newly cloned object

into different locations.
3. Repeat few times.
Local Score Problem
Press Run. We will see the local score problem. When we shoot a ball to
the same target, the score increase, but when we change the target, the
score will be reset to 1. We need to do the global score system.
Global Score System
1. Remove the duplicated target. 2. Select the target, and remove the Score Count component.
Global Score System #2
1. Create a new empty object, 

and name it "ScoreCounter"
2. Associate "ScoreCount.cs" code to

the ScoreCounter game object.
3. Create a new C# script file called

"DetectCollision.cs" and associate it

with the Target.
Global Score System #3
• Changing the method to other
name, like "IncreaseScore()"

• Add "public" in front of the
method to allow other classes
to call this method.

• By convention of the Unity, the
first letter of a method’s name
must be capitalized.
Edit your ScoreCount.cs to this content.
Global Score System #4
Make DetectCollision.cs call the ScoreCount’s Increase Score method, when there is a collision.
DetectCollision.cs
Run
Exercise 2: Create a target prefab.
• Use the prefab to make multiple targets

• Position them apart in the scene.

• Check if the score is update in one place.

• BONUS: If you can allow different targets to score differently.

• HINT: IncreaseScore() need an argument.
Making Multiple Scene
• We need the splash screen to
introduce the user about the game.

• We also need the end score screen to
show the final result of the game.

• We can make it by having multiple
scenes. One screen = One scene.
Making Multiple Scene #1
1. Create a new folder named "Scenes" 2. Move the scene that we already have 

into the Scenes folder by drag-and-drop.
3. Click, Press "Enter"

and rename it "2_Main"
Making Multiple Scene #2
4. Create a new Scene by right click, Create, Scene 5. Named it "1_Splash"
Making Multiple Scene #3
6. Double Click at the 1_Splash icon at the bottom panel, You will get the new empty scene.
Include Scenes into the Build
1. Go to File > Build Settings
2. Drag and drop both scenes into the "Scenes In Build".

***The order is very important***

"1_Splash" scene must be at the top of "2_Main" scene.
Moving one scene to another #1
1. Double click at the "1_Splash"
scene.

2. Create a new empty game
object named it "LevelManager"

3. Create a new C# script, named
it "LevelManager" as well.

4. Associate the C# script into the
Level Manager game object by
drag-and-drop.
Moving one scene to another #2
LevelManager.cs
Run
1_Splash
2_Main
SKIP IMMEDIATELY
Exercise 3: Trigger to next scene by spacebar
• Move from the 1_Splash scene to the 2_Main scene when user press
spacebar.

• Use GetKeyDown() method

• Seperate the logic for moving to the next scene in a new method.

• HINT: Edit at LevelManager.cs
Create Menu UI
1. Add the 1_Splash scene, change to 2D mode. 2. Create a new Canvas 3. Double click at "Canvas" game object

in the Hierarchy window or Zoom out a lot
(By middle mouse button).

You will see the boundary of the canvas.
Find image to put into canvas
1. Find in Google Image Search with the Noncommerical Reuse. 2. Download any image you like.
Import Images
1. Create a new folder called
"Images"

2. Drag and drop the download
image into that folder.
Add Image into Canvas
1. Select Canvas, Right click, UI, and Raw Image 2. Drag and drop the image into the RawImage’s Texture part.
Resize the Raw Image
• Make it bigger the canvas
by moving at the blue dot of
the Raw Image.

• Press Run to see the result.

• Try it in different screen
ratio. Resize the window in
different ways to make sure
that the raw image covered
all the display.
Exercise 4: Create a Game Over scene.
• Create a new scene

• Put it last in the build order.

• Add a canvas with the background image.

• Make it reachable from the game.
Adding Text into UI
1. Select the Canvas. Right-click, UI, Text
2. Select Text, Resize the text box by blue dot, Add text on the right

"Basketball Game", Change size, color, alignment as you wish.
Aerial is boring font.
1. Search Google for a matched font. 2. Download them.
Import Font into Unity
1. Create a new folder called "Fonts".

Drag and drop the font file into Unity
2. Select Text. Drag the font into Font box.

(GAME OF BRUSH font required ALL CAPITAL LETTERS)
Change text to match with the style.
Exercise 5: Complete Adding the Text
• Add "Hit space to play" instruction in the Splash Screen

• Add "Game Over" title in the Game Over Screen.

• Add "Hit space to try again" instruction in the Game Over Screen.

• Be Creative!!
Adding Button into UI
1. Add a button, by right-click at Canvas >

UI > Button.
2. Move the button to appropriate location.

Button always come with a text (as a child). 

Select the text, change front, change message as you wish.
Make it acts like a button
• Select the Button and
update their colors.

• Normal color

• Highlighted color

• Pressed color

• To give the feed back to
the user when the mouse
cursor is over a button.
Make Button OnClick() Working
1. Select Button. Press + at the On Click()

at the inspector window
2. Drag and drop the Level Manager Game Object to the OnClick Object Textbox
Make Button OnClick() Working #2
3. At LevelManager.cs

Add "public" at LoadNextScene() method 

to make it visible for Unity.
4. At the On Click() property of the button

Function > Level Manager > LoadNextScene()
Exercise 6: Add a "Play Again" Button
• Edit in the LevelManager script.

• You will need a LoadPreviousLevel() method.

• Add the button.

• Link it.
Adding Timer into the game!
Exercise 7: Progress after N seconds.
• Make the timeTillNextLevel configurable.

• Progress to next level when time run out.

• Make the default behavior to never progress.
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Update TimeTillNextLevel for each Scene
Q/A

More Related Content

What's hot (19)

Unity - Essentials of Programming in Unity
Unity - Essentials of Programming in UnityUnity - Essentials of Programming in Unity
Unity - Essentials of Programming in Unity
NexusEdgesupport
 
Run and jump tutorial (part 3) behaviours
Run and jump tutorial (part 3)   behavioursRun and jump tutorial (part 3)   behaviours
Run and jump tutorial (part 3) behaviours
Muhd Basheer
 
unity basics
unity basicsunity basics
unity basics
Reham Maher El-Safarini
 
DSC RNGPIT - Getting Started with Game Development Day 1
DSC RNGPIT - Getting Started with Game Development Day 1DSC RNGPIT - Getting Started with Game Development Day 1
DSC RNGPIT - Getting Started with Game Development Day 1
DeepMevada1
 
Game Development with Unity
Game Development with UnityGame Development with Unity
Game Development with Unity
davidluzgouveia
 
Hands On with the Unity 5 Game Engine! - Andy Touch - Codemotion Roma 2015
Hands On with the Unity 5 Game Engine! - Andy Touch - Codemotion Roma 2015Hands On with the Unity 5 Game Engine! - Andy Touch - Codemotion Roma 2015
Hands On with the Unity 5 Game Engine! - Andy Touch - Codemotion Roma 2015
Codemotion
 
Presentación Unity
Presentación UnityPresentación Unity
Presentación Unity
Laura Milena Parra Navarro
 
Unity 3D, A game engine
Unity 3D, A game engineUnity 3D, A game engine
Unity 3D, A game engine
Md. Irteza rahman Masud
 
2d game engine workflow
2d game engine workflow2d game engine workflow
2d game engine workflow
luisfvazquez1
 
Game Development with Unity - by Mickey MacDonald
Game Development with Unity - by Mickey MacDonaldGame Development with Unity - by Mickey MacDonald
Game Development with Unity - by Mickey MacDonald
Canada's Technology Triangle .NET User Group
 
Unity 3d
Unity 3dUnity 3d
Unity 3d
Srinivas Undinti
 
Unity introduction for programmers
Unity introduction for programmersUnity introduction for programmers
Unity introduction for programmers
Noam Gat
 
Academy PRO: Unity 3D. Environment
Academy PRO: Unity 3D. EnvironmentAcademy PRO: Unity 3D. Environment
Academy PRO: Unity 3D. Environment
Binary Studio
 
Unity Game Engine
Unity Game EngineUnity Game Engine
Unity Game Engine
Vardan Meliksetyan
 
Mobile Game Development in Unity
Mobile Game Development in UnityMobile Game Development in Unity
Mobile Game Development in Unity
Hakan Saglam
 
Systematic analysis of GWAP
Systematic analysis of GWAPSystematic analysis of GWAP
Systematic analysis of GWAP
Shih-Wen Huang
 
Game development -session on unity 3d
Game development -session on unity 3d Game development -session on unity 3d
Game development -session on unity 3d
Muhammad Maaz Irfan
 
Unity Introduction
Unity IntroductionUnity Introduction
Unity Introduction
Juwal Bose
 
Pb works howto
Pb works howtoPb works howto
Pb works howto
urse1515
 
Unity - Essentials of Programming in Unity
Unity - Essentials of Programming in UnityUnity - Essentials of Programming in Unity
Unity - Essentials of Programming in Unity
NexusEdgesupport
 
Run and jump tutorial (part 3) behaviours
Run and jump tutorial (part 3)   behavioursRun and jump tutorial (part 3)   behaviours
Run and jump tutorial (part 3) behaviours
Muhd Basheer
 
DSC RNGPIT - Getting Started with Game Development Day 1
DSC RNGPIT - Getting Started with Game Development Day 1DSC RNGPIT - Getting Started with Game Development Day 1
DSC RNGPIT - Getting Started with Game Development Day 1
DeepMevada1
 
Game Development with Unity
Game Development with UnityGame Development with Unity
Game Development with Unity
davidluzgouveia
 
Hands On with the Unity 5 Game Engine! - Andy Touch - Codemotion Roma 2015
Hands On with the Unity 5 Game Engine! - Andy Touch - Codemotion Roma 2015Hands On with the Unity 5 Game Engine! - Andy Touch - Codemotion Roma 2015
Hands On with the Unity 5 Game Engine! - Andy Touch - Codemotion Roma 2015
Codemotion
 
2d game engine workflow
2d game engine workflow2d game engine workflow
2d game engine workflow
luisfvazquez1
 
Unity introduction for programmers
Unity introduction for programmersUnity introduction for programmers
Unity introduction for programmers
Noam Gat
 
Academy PRO: Unity 3D. Environment
Academy PRO: Unity 3D. EnvironmentAcademy PRO: Unity 3D. Environment
Academy PRO: Unity 3D. Environment
Binary Studio
 
Mobile Game Development in Unity
Mobile Game Development in UnityMobile Game Development in Unity
Mobile Game Development in Unity
Hakan Saglam
 
Systematic analysis of GWAP
Systematic analysis of GWAPSystematic analysis of GWAP
Systematic analysis of GWAP
Shih-Wen Huang
 
Game development -session on unity 3d
Game development -session on unity 3d Game development -session on unity 3d
Game development -session on unity 3d
Muhammad Maaz Irfan
 
Unity Introduction
Unity IntroductionUnity Introduction
Unity Introduction
Juwal Bose
 
Pb works howto
Pb works howtoPb works howto
Pb works howto
urse1515
 

Similar to Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming (20)

Street runner final
Street runner finalStreet runner final
Street runner final
Kumar Narayan
 
Ui in unity
Ui in unityUi in unity
Ui in unity
Noam Gat
 
Unity workshop
Unity workshopUnity workshop
Unity workshop
fsxflyer789Productio
 
XNA in a Day
XNA in a DayXNA in a Day
XNA in a Day
Andrew Parsons
 
course1-Intrduction-to-the-game-industry.pdf
course1-Intrduction-to-the-game-industry.pdfcourse1-Intrduction-to-the-game-industry.pdf
course1-Intrduction-to-the-game-industry.pdf
BoubakerMedanas
 
Unity tutorial
Unity tutorialUnity tutorial
Unity tutorial
AkshatSingh144
 
Unity3d scripting tutorial
Unity3d scripting tutorialUnity3d scripting tutorial
Unity3d scripting tutorial
hungnttg
 
School For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine BasicsSchool For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine Basics
Nick Pruehs
 
Evolution Explosion - Final Year Project Presentation
Evolution Explosion - Final Year Project PresentationEvolution Explosion - Final Year Project Presentation
Evolution Explosion - Final Year Project Presentation
desirron
 
Workflow
WorkflowWorkflow
Workflow
crimzon36
 
Workflow
WorkflowWorkflow
Workflow
crimzon36
 
2D Endless Runner in Unity for Mobile - GDG DevFest Istanbul 2014
2D Endless Runner in Unity for Mobile - GDG DevFest Istanbul 20142D Endless Runner in Unity for Mobile - GDG DevFest Istanbul 2014
2D Endless Runner in Unity for Mobile - GDG DevFest Istanbul 2014
Murat Gürel
 
Game Development Session - 3 | Introduction to Unity
Game Development Session - 3 | Introduction to  UnityGame Development Session - 3 | Introduction to  Unity
Game Development Session - 3 | Introduction to Unity
Koderunners
 
Task two workflow by tom crook
Task two workflow by tom crookTask two workflow by tom crook
Task two workflow by tom crook
TomCrook
 
Easy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkeyEasy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkey
pprem
 
3 d platformtutorial unity
3 d platformtutorial unity3 d platformtutorial unity
3 d platformtutorial unity
unityshare
 
Game age ppt
Game age pptGame age ppt
Game age ppt
Ahmed Yousef
 
Md2010 jl-wp7-sl-game-dev
Md2010 jl-wp7-sl-game-devMd2010 jl-wp7-sl-game-dev
Md2010 jl-wp7-sl-game-dev
Jose Luis Latorre Millas
 
Monogame and xna
Monogame and xnaMonogame and xna
Monogame and xna
Lee Stott
 
Unity 3d scripting tutorial
Unity 3d scripting tutorialUnity 3d scripting tutorial
Unity 3d scripting tutorial
Blaž Gregorčič
 
Ui in unity
Ui in unityUi in unity
Ui in unity
Noam Gat
 
course1-Intrduction-to-the-game-industry.pdf
course1-Intrduction-to-the-game-industry.pdfcourse1-Intrduction-to-the-game-industry.pdf
course1-Intrduction-to-the-game-industry.pdf
BoubakerMedanas
 
Unity3d scripting tutorial
Unity3d scripting tutorialUnity3d scripting tutorial
Unity3d scripting tutorial
hungnttg
 
School For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine BasicsSchool For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine Basics
Nick Pruehs
 
Evolution Explosion - Final Year Project Presentation
Evolution Explosion - Final Year Project PresentationEvolution Explosion - Final Year Project Presentation
Evolution Explosion - Final Year Project Presentation
desirron
 
2D Endless Runner in Unity for Mobile - GDG DevFest Istanbul 2014
2D Endless Runner in Unity for Mobile - GDG DevFest Istanbul 20142D Endless Runner in Unity for Mobile - GDG DevFest Istanbul 2014
2D Endless Runner in Unity for Mobile - GDG DevFest Istanbul 2014
Murat Gürel
 
Game Development Session - 3 | Introduction to Unity
Game Development Session - 3 | Introduction to  UnityGame Development Session - 3 | Introduction to  Unity
Game Development Session - 3 | Introduction to Unity
Koderunners
 
Task two workflow by tom crook
Task two workflow by tom crookTask two workflow by tom crook
Task two workflow by tom crook
TomCrook
 
Easy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkeyEasy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkey
pprem
 
3 d platformtutorial unity
3 d platformtutorial unity3 d platformtutorial unity
3 d platformtutorial unity
unityshare
 
Monogame and xna
Monogame and xnaMonogame and xna
Monogame and xna
Lee Stott
 
Ad

More from Kobkrit Viriyayudhakorn (20)

Thai E-Voting System
Thai E-Voting System Thai E-Voting System
Thai E-Voting System
Kobkrit Viriyayudhakorn
 
Thai National ID Card OCR
Thai National ID Card OCRThai National ID Card OCR
Thai National ID Card OCR
Kobkrit Viriyayudhakorn
 
Chochae Robot - Thai voice communication extension pack for Service Robot
Chochae Robot - Thai voice communication extension pack for Service RobotChochae Robot - Thai voice communication extension pack for Service Robot
Chochae Robot - Thai voice communication extension pack for Service Robot
Kobkrit Viriyayudhakorn
 
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
Kobkrit Viriyayudhakorn
 
Thai Text processing by Transfer Learning using Transformer (Bert)
Thai Text processing by Transfer Learning using Transformer (Bert)Thai Text processing by Transfer Learning using Transformer (Bert)
Thai Text processing by Transfer Learning using Transformer (Bert)
Kobkrit Viriyayudhakorn
 
How Emoticon Affects Chatbot Users
How Emoticon Affects Chatbot UsersHow Emoticon Affects Chatbot Users
How Emoticon Affects Chatbot Users
Kobkrit Viriyayudhakorn
 
หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)
หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)
หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)
Kobkrit Viriyayudhakorn
 
Check Raka Chatbot Pitching Presentation
Check Raka Chatbot Pitching PresentationCheck Raka Chatbot Pitching Presentation
Check Raka Chatbot Pitching Presentation
Kobkrit Viriyayudhakorn
 
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
Kobkrit Viriyayudhakorn
 
[Lecture 4] AI and Deep Learning: Neural Network (Theory)
[Lecture 4] AI and Deep Learning: Neural Network (Theory)[Lecture 4] AI and Deep Learning: Neural Network (Theory)
[Lecture 4] AI and Deep Learning: Neural Network (Theory)
Kobkrit Viriyayudhakorn
 
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
Kobkrit Viriyayudhakorn
 
Lecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase AuthenticationLecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase Authentication
Kobkrit Viriyayudhakorn
 
Thai Word Embedding with Tensorflow
Thai Word Embedding with Tensorflow Thai Word Embedding with Tensorflow
Thai Word Embedding with Tensorflow
Kobkrit Viriyayudhakorn
 
Lecture 3 - ES6 Script Advanced for React-Native
Lecture 3 - ES6 Script Advanced for React-NativeLecture 3 - ES6 Script Advanced for React-Native
Lecture 3 - ES6 Script Advanced for React-Native
Kobkrit Viriyayudhakorn
 
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
Kobkrit Viriyayudhakorn
 
Startup Pitching and Mobile App Startup
Startup Pitching and Mobile App StartupStartup Pitching and Mobile App Startup
Startup Pitching and Mobile App Startup
Kobkrit Viriyayudhakorn
 
React Native Firebase Realtime Database + Authentication
React Native Firebase Realtime Database + AuthenticationReact Native Firebase Realtime Database + Authentication
React Native Firebase Realtime Database + Authentication
Kobkrit Viriyayudhakorn
 
React Native Firebase
React Native FirebaseReact Native Firebase
React Native Firebase
Kobkrit Viriyayudhakorn
 
React-Native Lecture 11: In App Storage
React-Native Lecture 11: In App StorageReact-Native Lecture 11: In App Storage
React-Native Lecture 11: In App Storage
Kobkrit Viriyayudhakorn
 
[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...
[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...
[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...
Kobkrit Viriyayudhakorn
 
Chochae Robot - Thai voice communication extension pack for Service Robot
Chochae Robot - Thai voice communication extension pack for Service RobotChochae Robot - Thai voice communication extension pack for Service Robot
Chochae Robot - Thai voice communication extension pack for Service Robot
Kobkrit Viriyayudhakorn
 
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
Kobkrit Viriyayudhakorn
 
Thai Text processing by Transfer Learning using Transformer (Bert)
Thai Text processing by Transfer Learning using Transformer (Bert)Thai Text processing by Transfer Learning using Transformer (Bert)
Thai Text processing by Transfer Learning using Transformer (Bert)
Kobkrit Viriyayudhakorn
 
หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)
หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)
หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)
Kobkrit Viriyayudhakorn
 
Check Raka Chatbot Pitching Presentation
Check Raka Chatbot Pitching PresentationCheck Raka Chatbot Pitching Presentation
Check Raka Chatbot Pitching Presentation
Kobkrit Viriyayudhakorn
 
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
Kobkrit Viriyayudhakorn
 
[Lecture 4] AI and Deep Learning: Neural Network (Theory)
[Lecture 4] AI and Deep Learning: Neural Network (Theory)[Lecture 4] AI and Deep Learning: Neural Network (Theory)
[Lecture 4] AI and Deep Learning: Neural Network (Theory)
Kobkrit Viriyayudhakorn
 
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
Kobkrit Viriyayudhakorn
 
Lecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase AuthenticationLecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase Authentication
Kobkrit Viriyayudhakorn
 
Lecture 3 - ES6 Script Advanced for React-Native
Lecture 3 - ES6 Script Advanced for React-NativeLecture 3 - ES6 Script Advanced for React-Native
Lecture 3 - ES6 Script Advanced for React-Native
Kobkrit Viriyayudhakorn
 
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
Kobkrit Viriyayudhakorn
 
React Native Firebase Realtime Database + Authentication
React Native Firebase Realtime Database + AuthenticationReact Native Firebase Realtime Database + Authentication
React Native Firebase Realtime Database + Authentication
Kobkrit Viriyayudhakorn
 
[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...
[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...
[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...
Kobkrit Viriyayudhakorn
 
Ad

Recently uploaded (20)

Integrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FMEIntegrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FME
Safe Software
 
Plooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your wayPlooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your way
Plooma
 
Making significant Software Architecture decisions
Making significant Software Architecture decisionsMaking significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 WebinarPorting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized InnovationAdvanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and DartStep by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
dp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdfdp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdf
pravkumarbiz
 
OpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native BarcelonaOpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native Barcelona
Imma Valls Bernaus
 
AI-Powered Compliance Solutions for Global Regulations | Certivo
AI-Powered Compliance Solutions for Global Regulations | CertivoAI-Powered Compliance Solutions for Global Regulations | Certivo
AI-Powered Compliance Solutions for Global Regulations | Certivo
certivoai
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWSWomen in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
Code and No-Code Journeys: The Coverage Overlook
Code and No-Code Journeys: The Coverage OverlookCode and No-Code Journeys: The Coverage Overlook
Code and No-Code Journeys: The Coverage Overlook
Applitools
 
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI SearchAgentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Maxim Salnikov
 
Who will create the languages of the future?
Who will create the languages of the future?Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
How to Choose the Right Web Development Agency.pdf
How to Choose the Right Web Development Agency.pdfHow to Choose the Right Web Development Agency.pdf
How to Choose the Right Web Development Agency.pdf
Creative Fosters
 
AI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA TechnologiesAI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA Technologies
SandeepKS52
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink TemplateeeeeeeeeeeeeeeeeeeeeeeeeeNeuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptxMOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
Integrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FMEIntegrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FME
Safe Software
 
Plooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your wayPlooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your way
Plooma
 
Making significant Software Architecture decisions
Making significant Software Architecture decisionsMaking significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 WebinarPorting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized InnovationAdvanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and DartStep by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
dp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdfdp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdf
pravkumarbiz
 
OpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native BarcelonaOpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native Barcelona
Imma Valls Bernaus
 
AI-Powered Compliance Solutions for Global Regulations | Certivo
AI-Powered Compliance Solutions for Global Regulations | CertivoAI-Powered Compliance Solutions for Global Regulations | Certivo
AI-Powered Compliance Solutions for Global Regulations | Certivo
certivoai
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWSWomen in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
Code and No-Code Journeys: The Coverage Overlook
Code and No-Code Journeys: The Coverage OverlookCode and No-Code Journeys: The Coverage Overlook
Code and No-Code Journeys: The Coverage Overlook
Applitools
 
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI SearchAgentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Maxim Salnikov
 
Who will create the languages of the future?
Who will create the languages of the future?Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
How to Choose the Right Web Development Agency.pdf
How to Choose the Right Web Development Agency.pdfHow to Choose the Right Web Development Agency.pdf
How to Choose the Right Web Development Agency.pdf
Creative Fosters
 
AI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA TechnologiesAI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA Technologies
SandeepKS52
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink TemplateeeeeeeeeeeeeeeeeeeeeeeeeeNeuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptxMOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 

Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming

  • 1. Lecture 4: Shoot Basketball Game #2 Dr. Kobkrit Viriyayudhakorn iApp Technology Limited [email protected] ITS488 (Digital Content Creation with Unity - Game and VR Programming)
  • 5. Download the Starting code • Go to https://github.com/ kobkrit/VR_basketball_lecture_3 to download the starting code. • Unzip the project. • Open Unity. • Open the project by selecting the unzipped folder.
  • 6. Object Collider Click at a Ground Game Object. Uncheck the Sphere Collider and Press "Run" to see the effect.
  • 7. Collision • We can check the collision between objects in Unity very easy. • To demonstrate, We will create a mini shooter game which use a cube as a target. • If user shoot a ball that hit the target, user get a score.
  • 8. Collision: Adding Target 1. Right click to create cube as the target. 2. Move the target to the center of the field. 
 Make it see within camera.
  • 9. Collision: Counting Score 3. Change the name of the cube in the inspector,
 as "Target" 4. Add the C# Script 5. Name it as "Score Count" and Make it associated with the "Target".
  • 10. Collision: OnCollsionEnter Method 6. Adding the OnCollisionEnter method. 7. Run
  • 11. Exercise 1 • Modify the ScoreCount.cs code to be able to count the score. • When a ball hit the target, the score increases by 1. • Print out the score by
 print() command.
  • 12. Add multiple targets • To complete the game, we are going to have multiple targets, as we have designed to have multiple basketball’s backboards • We will cloning the target into 2-3 targets. • Move the newly cloned target to different locations.
  • 13. Duplicate the target 1. Select the target, right click,
 select "Duplicate". 2. Move the newly cloned object
 into different locations. 3. Repeat few times.
  • 14. Local Score Problem Press Run. We will see the local score problem. When we shoot a ball to the same target, the score increase, but when we change the target, the score will be reset to 1. We need to do the global score system.
  • 15. Global Score System 1. Remove the duplicated target. 2. Select the target, and remove the Score Count component.
  • 16. Global Score System #2 1. Create a new empty object, 
 and name it "ScoreCounter" 2. Associate "ScoreCount.cs" code to
 the ScoreCounter game object. 3. Create a new C# script file called
 "DetectCollision.cs" and associate it
 with the Target.
  • 17. Global Score System #3 • Changing the method to other name, like "IncreaseScore()" • Add "public" in front of the method to allow other classes to call this method. • By convention of the Unity, the first letter of a method’s name must be capitalized. Edit your ScoreCount.cs to this content.
  • 18. Global Score System #4 Make DetectCollision.cs call the ScoreCount’s Increase Score method, when there is a collision. DetectCollision.cs
  • 19. Run
  • 20. Exercise 2: Create a target prefab. • Use the prefab to make multiple targets • Position them apart in the scene. • Check if the score is update in one place. • BONUS: If you can allow different targets to score differently. • HINT: IncreaseScore() need an argument.
  • 21. Making Multiple Scene • We need the splash screen to introduce the user about the game. • We also need the end score screen to show the final result of the game. • We can make it by having multiple scenes. One screen = One scene.
  • 22. Making Multiple Scene #1 1. Create a new folder named "Scenes" 2. Move the scene that we already have 
 into the Scenes folder by drag-and-drop. 3. Click, Press "Enter"
 and rename it "2_Main"
  • 23. Making Multiple Scene #2 4. Create a new Scene by right click, Create, Scene 5. Named it "1_Splash"
  • 24. Making Multiple Scene #3 6. Double Click at the 1_Splash icon at the bottom panel, You will get the new empty scene.
  • 25. Include Scenes into the Build 1. Go to File > Build Settings 2. Drag and drop both scenes into the "Scenes In Build".
 ***The order is very important***
 "1_Splash" scene must be at the top of "2_Main" scene.
  • 26. Moving one scene to another #1 1. Double click at the "1_Splash" scene. 2. Create a new empty game object named it "LevelManager" 3. Create a new C# script, named it "LevelManager" as well. 4. Associate the C# script into the Level Manager game object by drag-and-drop.
  • 27. Moving one scene to another #2 LevelManager.cs
  • 29. Exercise 3: Trigger to next scene by spacebar • Move from the 1_Splash scene to the 2_Main scene when user press spacebar. • Use GetKeyDown() method • Seperate the logic for moving to the next scene in a new method. • HINT: Edit at LevelManager.cs
  • 30. Create Menu UI 1. Add the 1_Splash scene, change to 2D mode. 2. Create a new Canvas 3. Double click at "Canvas" game object
 in the Hierarchy window or Zoom out a lot (By middle mouse button).
 You will see the boundary of the canvas.
  • 31. Find image to put into canvas 1. Find in Google Image Search with the Noncommerical Reuse. 2. Download any image you like.
  • 32. Import Images 1. Create a new folder called "Images" 2. Drag and drop the download image into that folder.
  • 33. Add Image into Canvas 1. Select Canvas, Right click, UI, and Raw Image 2. Drag and drop the image into the RawImage’s Texture part.
  • 34. Resize the Raw Image • Make it bigger the canvas by moving at the blue dot of the Raw Image. • Press Run to see the result. • Try it in different screen ratio. Resize the window in different ways to make sure that the raw image covered all the display.
  • 35. Exercise 4: Create a Game Over scene. • Create a new scene • Put it last in the build order. • Add a canvas with the background image. • Make it reachable from the game.
  • 36. Adding Text into UI 1. Select the Canvas. Right-click, UI, Text 2. Select Text, Resize the text box by blue dot, Add text on the right
 "Basketball Game", Change size, color, alignment as you wish.
  • 37. Aerial is boring font. 1. Search Google for a matched font. 2. Download them.
  • 38. Import Font into Unity 1. Create a new folder called "Fonts".
 Drag and drop the font file into Unity 2. Select Text. Drag the font into Font box.
 (GAME OF BRUSH font required ALL CAPITAL LETTERS) Change text to match with the style.
  • 39. Exercise 5: Complete Adding the Text • Add "Hit space to play" instruction in the Splash Screen • Add "Game Over" title in the Game Over Screen. • Add "Hit space to try again" instruction in the Game Over Screen. • Be Creative!!
  • 40. Adding Button into UI 1. Add a button, by right-click at Canvas >
 UI > Button. 2. Move the button to appropriate location.
 Button always come with a text (as a child). 
 Select the text, change front, change message as you wish.
  • 41. Make it acts like a button • Select the Button and update their colors. • Normal color • Highlighted color • Pressed color • To give the feed back to the user when the mouse cursor is over a button.
  • 42. Make Button OnClick() Working 1. Select Button. Press + at the On Click()
 at the inspector window 2. Drag and drop the Level Manager Game Object to the OnClick Object Textbox
  • 43. Make Button OnClick() Working #2 3. At LevelManager.cs
 Add "public" at LoadNextScene() method 
 to make it visible for Unity. 4. At the On Click() property of the button
 Function > Level Manager > LoadNextScene()
  • 44. Exercise 6: Add a "Play Again" Button • Edit in the LevelManager script. • You will need a LoadPreviousLevel() method. • Add the button. • Link it.
  • 45. Adding Timer into the game!
  • 46. Exercise 7: Progress after N seconds. • Make the timeTillNextLevel configurable. • Progress to next level when time run out. • Make the default behavior to never progress.
  • 49. Q/A