ACADEMIC YEAR: 2024-25
Course: User Experience Design with VR Lab
Course code: CSDOL7021
Year/Sem: BE/VII
Experiment No.: 5
Aim: Develop a scene in Unity: Create a plane and a sphere, Apply Rigid
Body component, material and Box Collider to the game objects, Write a
C# program to grab and throw the sphere using VR controllers.
Name: Sahil Kadam
Roll Number: 66
Date of Performance:
Date of Submission:
Evaluation
Performance Indicator Max. Marks Marks Obtained
Performance 5
Understanding 5
Journal work and timely submission. 10
Total 20
Performance Exceed Expectations Meet Expectations Below Expectations
Indicator (EE) (ME) (BE)
Performance 5 3 2
Understanding 5 3 2
Journal work and
10 8 4
timely submission.
Checked by
Name of Faculty : Ms. Rujuta Vartak
Signature :
Date :
CSDOL7021: User Experience Design with VR Lab
EXPERIMENT NO. 5
Aim: Develop a scene in Unity: Create a plane and a sphere, Apply Rigid Body component,
material and Box Collider to the game objects, Write a C# program to grab and throw the
sphere using VR controllers.
Theory:
The intersection of physics and virtual reality (VR) encompasses a range of applications,
technologies, and research areas.
Applications
1. Educational Simulations:
o VR can create immersive environments for learning complex physics concepts.
For instance, students can visualize and interact with three-dimensional models
of atoms, explore gravitational fields, or observe the effects of forces and
motion in real-time.
2. Scientific Research:
o Physicists can use VR to simulate experiments that are difficult or impossible
to conduct in the real world. For example, VR can be used to model subatomic
particles' behavior or simulate astrophysical phenomena like black holes or
galaxy formations.
3. Training and Visualization:
o VR can be used for training purposes in fields requiring an understanding of
physics, such as engineering, aerospace, and medicine. It allows professionals
to visualize complex physical processes and practice in a risk-free environment.
Technologies
1. Physics Engines:
o VR relies on physics engines to create realistic interactions within the virtual
environment. These engines simulate the laws of physics, including gravity,
collisions, fluid dynamics, and rigid body dynamics, to make virtual objects
behave as they would in the real world.
2. Haptics:
o Haptic technology enhances VR experiences by providing tactile feedback to
users, allowing them to feel virtual objects. This is crucial for simulating
physical interactions in VR, such as touching, grabbing, or manipulating
objects.
3. Motion Tracking:
CSDOL7021: User Experience Design with VR Lab
o Accurate motion tracking is essential for realistic physics simulations in VR.
This involves tracking the user's movements and translating them into the
virtual environment, ensuring that interactions follow physical laws accurately.
Research Areas
1. Virtual Laboratories:
o Researchers are developing virtual laboratories where physical experiments can
be conducted in a controlled, simulated environment. These virtual labs are
particularly useful in educational settings and for remote research
collaborations.
2. Human-Computer Interaction (HCI):
o The study of how humans interact with VR environments involves
understanding the physics of human motion and developing interfaces that
accurately capture and respond to these movements.
3. Real-Time Physics Simulation:
o Advances in real-time physics simulation are crucial for making VR
experiences more immersive and believable. Researchers work on optimizing
algorithms to handle complex physical interactions in real-time without
compromising performance.
By combining VR with physics, we can create powerful tools for education, research, and
professional training, making abstract concepts tangible and providing new ways to explore
and interact with the physical world.
Problem Statement:
Develop a scene in Unity includes a sphere & plane. Apply Rigid body component, material &
Box collider to the game objects. Grab & throw the sphere using a VR Controller.
Steps:
Creating the Scene:
• Create a plane, sphere & a cube; scale them as the picture.
• Apply different materials to them.
• The cube will be used as a table on which the sphere will be placed upon.
Physics: Colliders
CSDOL7021: User Experience Design with VR Lab
• Unity handles collision between GameObjects with Colliders, which attach to
GameObjects and define the shape of a GameObject for the purposes of physical
collisions.
• A collider is invisible, and does not need to be the exact same shape as the
GameObject’s mesh.
• The simplest (and least processor- intensive) colliders are primitive collider types. In
3D, these are the Box Collider, Sphere Collider and Capsule Collider.
Physics: Rigidbody
• Rigidbodies are components that allow a GameObject to react to real-time physics.
• This includes reactions to forces and gravity, mass, drag and momentum.
• The 2 vital flags of RigidBody are: Use Gravity & Is Kinematic.
• If isKinematic is enabled, Forces, collisions or joints will not affect the rigidbody
anymore. The rigidbody will be under full control of animation or script control by
changing transform.position.
• Use Gravity controls whether gravity affects this rigidbody. If set to false the rigidbody
will behave as in outer space.
Physics Application:
• Setup the Transform, Colliders & Rigidbody components of the sphere & cube as
following images & Play the scene.
• The sphere will fall down on the table & stay there.
• The physics calculations are done by Unity engine.
VR by using XR Interaction Toolkit:
• Unity has created a package called “XR Interaction Toolkit” by which we can create
VR enabled applications for a wide range of VR Headsets.
• To install the XR Interaction Toolkit package go to Window -> Package Manager.
CSDOL7021: User Experience Design with VR Lab
• Click on the “Packages:Unity Project” dropdown in the top left corner & select “Unity
Registry”.
• Click on the plus icon on the top left corner of the package manager window & click
“Add package by name” & type the following: com.unity.xr.interaction.toolkit
After installation, update the package if necessary.
1. Additionally search & install these packages if they aren’t already installed:
○ XR Plugin Management
○ Oculus XR Plugin
2. Unity might ask to restart the project, click yes if it does.
VR by using XR Interaction Toolkit:
• Now close the package manager window & go to Edit -> Project settings.
• Click on XR Plug In Management Tab in the bottom left.
• On the right side, Check the oculus checkbox as said in the Image.
Creating the XROrigin:
1. The XR Origin represents the center of worldspace in an XR scene.
2. The purpose of the XR Origin is to transform objects and trackable features to their final
position, orientation, and scale in the Unity scene. It specifies an Origin, a Camera Floor Offset
Object, and a Camera.
3. In the hierarchy, right click -> XR -> Device Based - > XROrigin.
4. Set the Transform position of the XROrigin at 0, 0,0. Set the Tracking Origin Mode field of
the XR Origin component to Floor.
5. Expand the hierarchy of XROrigin (Tip: left arrow besides the object in Hierarchy).
CSDOL7021: User Experience Design with VR Lab
6. Select the LeftHand Controller & remove the XR Ray Interactor, XR Interactor Line Visual,
Line Renderer components from it. Add XR Direct Interactor & Sphere Collider to it. Set the
Sphere Collider values acc to the image. Do the same for the RightHand Controller.
Play & Check:
● Do the setup of the oculus link software. Software Link -
https://store.facebook.com/quest/setup/
● Connect the Oculus Headset to the PC with a wire & Play the game.
● If everything is setup correctly, you should be able to see the camera move in Game scene
when you wear the Oculus headset.
Adding Hands:
1. As of now we can’t see our controllers (hands) so we will solve that next
2. Create a sphere in the scene.
3. Give it a material.
4. Remove the sphere collider from it.
5. Set it’s position at 0,0,0 & Scale the game object down to 0.1, 0.1, 0.1 (Tip:- Transform)
6. Create a Prefab of it & delete it from the scene.
7. Now assign the prefab to the Model Prefab field of Left Hand Controller & Right Hand
Controller.
Play the Game:
● Play the Game & watch the hands in game.
● Notice how they move when you move the controllers in real time.
CSDOL7021: User Experience Design with VR Lab
Adding Locomotion:
1. To move in game we need to add a few components.
2. To the XROrigin gameobject, Add Component Character Controller & Character Controller
Driver.
3. To the XR Interaction Manager gameobject add the following components- Continuous
Move Provider (Device Based), Locomotion System, Snap Turn Provider (Device Based).
4. Set up the Continuous Move Provider & Snap Turn Provider as specified in the image.
Play the Game:
● Play the Game & move in game with the left controller’s joystick.
● Turn in game with the help of right controller’s joystick.
Interaction In VR:
1. In XR Interaction Toolkit, there are two main types of categories:
○ Interactors
○ Interactables
2. Interactor: An interactor is a gameobject with the interactor component with some way of
interacting with the Interactables.
○ 3 main types of interactors are: Direct Interactor, Socket Interactor, Ray Interactor
3. Interactable: An interactable is an object with the Interactable component which can be
interacted with by the Interactors.
○ Eg: Grab Interactable
Making the sphere grabbable:
1. Select the sphere that has gravity & add the XRGrabInteractable component to it.
CSDOL7021: User Experience Design with VR Lab
2. Set it up like the image suggests.
Play the Game:
● Play the Game & try to grab the sphere from the table with the help of a controller.
● Notice that after grabbing the sphere it doesn’t pass through the table.
Output:
CSDOL7021: User Experience Design with VR Lab
Conclusion:
Name some example projects and experiments based on interaction between physics and VR.
1. Newton's Laws of Motion in VR:
o This project simulates real-world physics using VR to demonstrate concepts like
inertia, force, and acceleration. Users can interact with objects in virtual
environments to see how forces affect motion in real time.
2. VR Simulations for Quantum Mechanics:
o Experiments in VR provide a 3D interactive visualization of quantum
phenomena, such as wave-particle duality and probability fields. Users can
explore abstract concepts like particle interactions in ways that are difficult to
grasp through traditional methods.
3. Gravitational Simulation in VR:
o A VR project simulating gravity fields allows users to visualize and manipulate
celestial bodies, exploring the effects of gravitational forces on planetary orbits
and other astrophysical phenomena.
CSDOL7021: User Experience Design with VR Lab
4. VR Fluid Dynamics Simulation:
o This project simulates fluid movement in a virtual environment, demonstrating
complex physics principles like turbulence and flow. Users can interact with
different fluid properties and see how they behave in real time.
5. VR Electromagnetic Field Experiment:
o In this experiment, users visualize and interact with electric and magnetic fields
in a 3D space. It provides a hands-on experience for understanding how
electromagnetic forces work and how they affect objects in the environment.
These projects blend physics principles with VR's immersive capabilities, allowing users to
experience and interact with complex phenomena in a more intuitive and engaging way.
CSDOL7021: User Experience Design with VR Lab
CSDOL7021: User Experience Design with VR Lab
CSDOL7021: User Experience Design with VR Lab
CSDOL7021: User Experience Design with VR Lab
CSDOL7021: User Experience Design with VR Lab