[go: up one dir, main page]

0% found this document useful (0 votes)
15 views21 pages

Module 3a - VR Events Interaction

The BCM3103 Virtual Reality module focuses on enhancing VR experiences through audio and haptic feedback, as well as implementing interactive elements like a TV and remote control. Students will learn to add immersive audio effects, create responsive interactions, and program objects to react to user inputs. The module culminates in the ability to control a TV using a remote, complete with sound and visual feedback.

Uploaded by

Ariff Iskandar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views21 pages

Module 3a - VR Events Interaction

The BCM3103 Virtual Reality module focuses on enhancing VR experiences through audio and haptic feedback, as well as implementing interactive elements like a TV and remote control. Students will learn to add immersive audio effects, create responsive interactions, and program objects to react to user inputs. The module culminates in the ability to control a TV using a remote, complete with sound and visual feedback.

Uploaded by

Ariff Iskandar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

BCM3103 VIRTUAL REALITY

SEMESTER 2 2022/2023

BCM3103 VIRTUAL REALITY


MODULE 3a: VR EVENTS & INTERACTION [2Hours]
This module is a continuation of Module 2_VR Basic. Do make sure you already
completed Module 2 before beginning this module.
In this module, you will implement more complex interactions in VR based to make the
experience more immersive. These interactions include:
♦ implementing audio and haptic feedback
♦ applying new functionality to specific objects

A – Audio and Haptics [1 Hours]


In this module, you will learn how to:
♦ Increase the immersion of your project through touch and audio stimuli.
♦ The user will receive haptic and auditory feedback when they hover over or grab
an object.
♦ There will also be 3D spatial ambient sound in the scene.
A1 – Add Haptic Feedback On Hover and Select Enter
Note: If you are using the OpenXR plug-in for development on devices like the HTC Vive
or Valve index, this feature may not work
1. To begin, you’ll need to edit both controller objects at the same time. How?
2. In the Hierarchy > expand XR Rig > Expand Camera Offset > Ctrl + select both
the RightHand Controller and LeftHand Controller.
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

3. After selecting both controllers. In Inspector > XR Ray Interactor component >
Locate the Haptic Events > Expand the fold out

a. To create subtle haptic feedback when the user hovers over an object
Click the On Hover Entered checkbox > Set the intensity to a low value:
0.1 – 0.5 > Set the Duration to a very low value: 0.1 seconds
b. To create more noticeable feedback when the user grabs an object
Click the On Select Entered checkbox > Set the Intensity and Durations
values to slightly higher values: 0.25 seconds

4. Save & play. Now, your controllers should vibrate subtly when you hover over an
object and slightly more when you select an object.
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

A2 – Add Audio Feedback on either Hover or Select Enter


5. To add Audio Feedback, you’ll need to select the sound you want to use. In
Project > _Course Library > Audio > FX > determine which subtle UI Sound
Effect you want to hover or select event

**To preview the sound, select the one of the sounds > In Inspector > At the
bottom of the component > Play

6. Now, apply the sound effect to both controller by selecting both controllers again
(Refer earlier tutorial) > In Inspector > XR Ray Interactor > Expand the Audio
Events fold-out
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

7. Click to enable either On Select Entered or the On Hover Entered > Then,
assign the sound effect

8. Save & play. You should now hear a sound effect either when you hover over the
object or when you select the object
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

A3 – Add Spatialize Audio


In addition to audio feedback on events, you can add 3D spatial audio into the scene
emanating from the fireplace to increase immersion
9. Add Fireplace into your environment > In Project > _Course Library > _Prefabs >
Fireplace > Drag your chosen Fireplace into the scene

a. To give the fire a sound effect


In Hierarchy > Select the Particle_Fire gameObject > In Inspector > Add
Component > Audio Source
In Project > _Course Library > Audio > FX > Select SFX_Loop_Fire
Drag SFX_Loop_Fire into AudioClip (In Inspector > Audio Source)
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

b. To make the sound automatically and loop


In Audio Source Component > make sure both the Play On Awake and
Loop settings are enabled
Adjust the Spatial Blend property to configure this component as 3D
Sound by dragging the slider all the way to the right 3D setting
Edit the Volume property > Expand the 3D Sound Setting fold-out > adjust
Min Distance and Max Distance value
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

10. Save & play. The fireplace should now make a crackling sound, which should
change in volume and left/right balance depending on where you are located and
oriented in the scene
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

A4 – Add a Reverb Zone


To maintain a sense of presence in VR, it’s especially important to make sure audio
behaves the way it would in the real world. This includes considering how sounds might
reverberate around different kinds of rooms.
11. Add a new Audio Reverb Zone as a child of the Room object. In Hierarchy > Select
Room_[Style] gameObject > In Inspector > Add Component > Audio Reverb Zone
component

12. To make the Audio Reverb Zone component encompassed the whole room, make
sure the Min Distance property is set to at least the width of the room
13. In Inspector > Audio Reverb Zone > Min Distance: 5 and Max Distance:15 (This is
not the fixed value. You may change accordingly.
14. You may use the ReverbPreset drop down to experiment with different styles or
reverbs.

15. Save & play. You should now have a reverb zone set up in your room to make the
3D sound even more realistic.
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

B – Activation Events [1 Hours]


In this module, you will learn how to:
♦ Add unique functionality to an object when the user interacts with it in a certain
way.
♦ By the end of this lesson, users will be able to pick up a remote and press a
button on a controller to turn on a TV
B1 – Add TV and a grabbable remote-control object
Up to this point, you have only been able to pick up and put down objects. Now, you will
add an object that you can do something with - or “activate” - once it’s in your hand
1. Add TV and remote-control object into your scene
From Project > _Course Library > _Prefabs > Televisions – Drag your selected TV
into the scene > Reposition the TV
From Project > _Course Library > _Prefabs > Objects > Electronics – Drag the
remote object into the Scene > Reposition
2. Set the object as grabbable object. If you don’t remember how, do follow this
step:
In Hierarchy > Select Remote object
In Inspector > Add Component > Add XR Grab Interactable – this will
automatically add the RigidBody component onto the object
Expand the RigidBody component > Set Collision Detection: Continuous Dynamic
to avoid the object from fall through the floor
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

3. Position the remote correctly in the player’s hand when it is picked up. In
Hierarchy > Select Remote object > Right click > create empty > Rename as
Attach – make sure this object is a child for remote object
4. Select Attach object – Position and orient the Attach object appropriately
5. In Hierarchy > Select Remote > In Inspector > XR Grab Interactable > Drag
Attach object onto Attach Transform
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

6. Save & play. Try to grab the remote. You should now be able to pick up the
remote in a way that looks natural.
B2 – Play a sound when activate the remote
Now you will make the remote make a click sound when you are holding it and press the
trigger.
7. In Hierarchy > Select Remote object > In Inspector > Add Component > Audio
Source
8. In Audio Source Component > Spatial Blend property > slide the property to 3D
to allow for 3D audio
9. To give the remote the ability to play a sound – In Inspector > Add Component >
Play Quick Sound
10. For the sound property – assign an audio clip from _Course Library > Audio > FX
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

11. Now, Locate the remote’s “On Activated” event


a. Select Remote object > In Inspector > XR Grab Interactable component >
Expand Interactable Events – you can find all the event option

b. Locate On Activated event > click the + to add new action > Drag and
drop the Remote object to the empty Object slot in order to access it
component > Click the No Function drop down > Select PlayQuickSound
> Play ()
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

12. Save & play. With the remote in your hand, you should now be able to press the
activate button, the controller trigger, and hear a sound.
B3 – Change the remote’s indicator light color when activated
To provide additional feedback that the remote has been pressed, you can also turn the
indicator light red when the remote is activated
13. To add the capability for the indicator light to turn red – In Hierarchy > Remote
object > Select Indicator_Light child object > Go to Inspector > Add Component
> Add Change Material component > Other Material: Assign a RedGlow material
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

14. Now, change the material color to redGlow when the trigger is pressed – In
Hierarchy > Select Remote object > In Inspector > XR Grab Interactable
component > Expand Interactable Events > On Activated > Click the + to add
new function

15. Drag Indicator_Light object onto Object Property > Click the No Function drop
down > Change Material > SetOtherMaterial() function
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

16. Now, make the material revert when the activate button is released – Select
Remote Object > In Inspector > XR Grab Interactable > Interactable Events > On
Deactivated > click + to add new function > Assign the Indicator_Light object >
Select ChangeMaterial > SetOriginalMaterial() function
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

17. Save & play. When you activate the remote, the indicator light should turn red
and then revert to its original color when the activate button is released.
18. To activate the remote, when you pick up the remote > left click
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

B4 – Make the TV play video


Before you get the button set up to turn the TV on, you should make sure the TV in the
scene can successfully play video.
19. In Hierarchy > Select TV_[Style] > Screen (child to TV) > Go to Inspector > Add
Component > Audio Source > Drag Spatial Blend property to full 3D to enable
spatial audio

20. Then, Add Component > Video Player > Change Material Property to _BaseMap
to project the video to its material rather than its texture
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

21. Then, while selecting the Screen object > In Inspector > Add Component > Play
Video (Script) > Click the Play At Start check box
22. To select the video to play on the screen - Go to Play Video Component >
expand the Video Clips > Set the list Size property to 1 and Enter to reveal an
empty Video Clip slot
23. Assign one of the videos from the _Course Library > Videos to the Video Clip
Property

24. Save & play. Now when you run your application, the video should play
automatically on the TV Screen with 3D audio
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

B4 – Control the TV with remote control


Now that the TV is working, you need to be able to control it with the remote
25. Earlier, we set the enable the Play At Start property. This causes the TV to play
automatically when we play the application.
26. Now, stop the video from playing automatically > Select Screen object > In
Inspector > Play Video component > Disable Play At Start property

27. In Hierarchy > Select Remote object > In Inspector > XR Grab Interactable >
Expands Interactable Events fold out > On Activated > click + to add new
functions
28. Assign the Screen object to the Empty Object Property > Click the No Function
drop-down and select the PlayVideo > TogglePlayPause () function, or the
PlayVideo > TogglePlayStop () function, depending on whether you want it to
pause or stop when pressed a second time
BCM3103 VIRTUAL REALITY
SEMESTER 2 2022/2023

29. Save & play. When you activate the remote, the video on the TV should alternate
between playing and pausing or stopping

You might also like