Upload
kobkrit-viriyayudhakorn
View
225
Download
0
Embed Size (px)
Citation preview
Lecture 6: Music and Sound Effect& GVR Try out.
Dr. Kobkrit ViriyayudhakorniApp Technology Limited
ITS488 (Digital Content Creation with Unity - Game and VR Programming)
Starter Project
https://github.com/kobkrit/VR_basketball
Sound Effect
Getting Resource from Unity Asset Store
Audio Kit
Download Audio Kit at http://bit.ly/2iVDB7v
Import Audio Kit
1. Menu Bar > Assets > Import Package > Custom Package...
2. Select the "AudioKit.unitypackage"
3. Make sure that all files are selected, and then
Press "Import"
Imported Audio
Press to Play
Adding Music to the Game
1. Select "Scene 1". Right click at Hierarchy > Audio > Audio Source
2. Drag the "music...come..."to the Audio Source
Configure the Music
1. Select Audio Source
2. Checked at • Play On Awake• Loop
3. Run "Play" to Test.
Exercise 1: Add a sound to Game Over.
• Find the sound that seems most appropriate to you.
• Should it be looping or not?
• Add the audio source to the Game Over scene.
Adding Sound Effect to Ball
1. Open the Scene 2 > ShootHoopKit > Drag the ball to the Hierarchy windows
2. Select the ball at the right inspector windows >Add Component > Audio Source
3. The attached audio sourceis added into the Ball Game object
Trigger Sound Effect by Code
1. Drag a drop Sound file. the impact_deep_thud_bounce sound file into the AudioClip 2. Add the new C# script, "BallBounceSound.cs"
BallBounceSound.cs
2. Drag the BallBounceSound.cs to attached with the ball game object. >>
1. Writing the above code.
Trigger Sound Effect by Code
Make the customized ball as the prefab
1. Press "Play" now, We will heard only the single drop of sounds.
Even you firing multiple ball.
2. Drag the customized ball as the ball prefab.
3. Press Play again.Now you will heard multiple
drop sounds.
Exercise 2: Adding a scoring sound.
• Add an audio source component.
• Find a good scoring sound.
• Trigger in the appropriate place.
Solution for Exercise 2• Enter the ScoreCount.cs, Add the AudioSource part at IncreaseScore Function.
1. Select "ScoreCount" Game Object,At the inspector windows, Add "Audio source".
2. Drag and drop "Chime_ball_02" at the AudioClip part.Unchecked "Play On Awake checkbox.
Play with sound time.
Make our life easier with Google VR SDK
Google VR Installation• https://developers.google.com/vr/unity/download
Making a new project
Import GVR unity package
1. Assets > Import Package > Custom Package....
2. Select GoogleVRForUnity_1.110.0.unitypackage
3. Make sure that all items are checkedand then "Import"
Google VR Demo
Play around with GVR Demo
1. File > Build Settings...
1. Tap "Add Open Scenes" 2. Select iOS 3. Click "Switch Platform"
Change to Virtual Reality Project
1. Click on "Player Settings"
2. At the XR Settings,Select "Virtual Reality Supported" and Add "Cardboard" to Virtual Reality SDK
Test on iOS
1. Connect with iOS phone to the machine.2. Press "Build and Run"
Fast VR project using GVR
1. Create a New Empty Scene2. Add Cube into the Scene,
Make it in front of the Camera3. Play
You can not move any view.
1. Go to Google VR Assets > Prefabs
Using GVR Prefab
2. Import the prefab like this...
Now you can move in VR
• Shift + Move Mouse = Change Orientation • Shift + Left Mouse Button = ClickButton • Shift + Right Mouse Button = AppButton • Shift + Middle Mouse Button = HomeButton/Recenter • Shift + Ctrl = IsTouching • Shift + Ctrl + Move Mouse = Change TouchPos
There is much more in Google VR• A simple reticle prefab and associated scripts for gaze-based user interaction.
• User head tracking.
• Side-by-side stereo rendering.
• Detecting user interaction with the system (via trigger or controller).
• Automatic stereo configuration for a specific VR viewer.
• Distortion correction for a VR viewer's lenses.
• An alignment marker to help center the screen under the lenses when you insert your phone into a viewer.
• Automatic gyro drift correction.
Q/A