O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unity Virtual Reality Projects - Second Edition

Book Description

Explore the latest features of Unity 2018 to create immersive VR projects for Oculus Rift, HTC Vive, Daydream and Gear VR

About This Book
  • A project-based guide to teach you how to develop immersive and fun VR applications using Unity 3D
  • Build experiences with interactable objects, physics, UI, animations, C# scripting, and other Unity features
  • Explore the world of VR by building experiences such as diorama, first-person characters, 360-degree projections, social VR, audio fireball game, and VR storytelling
Who This Book Is For

If you're a non-programmer unfamiliar with 3D computer graphics, or experienced in both but new to virtual reality, and are interested in building your own VR games or applications, then this book is for you. Any experience in Unity is an advantage.

What You Will Learn
  • Create 3D scenes with Unity and other 3D tools while learning about world space and scale
  • Build and run VR applications for specific headsets, including Oculus, Vive, and Daydream
  • Interact with virtual objects using eye gaze, hand controllers, and user input events
  • Move around your VR scenes using locomotion and teleportation
  • Implement an audio fireball game using physics and particle systems
  • Implement an art gallery tour with teleportation and data info
  • Design and build a VR storytelling animation with a soundtrack and timelines
  • Create social VR experiences with Unity networking
In Detail

Unity has become the leading platform for building virtual reality games, applications, and experiences for this new generation of consumer VR devices.

Unity Virtual Reality Projects walks you through a series of hands-on tutorials and in-depth discussions on using the Unity game engine. With its practical and project-based approach, this book will get you up to speed with the specifics of Virtual Reality development in Unity. You will learn how to use Unity to develop VR applications that can be experienced with devices such as Oculus, Daydream, and Vive. Among the many topics and projects, you will explore gaze-based versus hand controller input, world space UI canvases, locomotion and teleportation, software design patterns, 360-degree media, timeline animation, and multiplayer networking. You will learn the Unity 3D game engine via the interactive Unity Editor as well as C# programming. By the end of the book, you will be fully equipped to develop rich, interactive virtual reality experiences using Unity.

Style and approach

A practical step-by-step guide to building impressive VR experiences with Unity 2018.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Unity Virtual Reality Projects Second Edition
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the project assets and example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  7. Virtually Everything for Everyone
    1. What is virtual reality to you?
    2. Types of head-mounted displays
      1. Desktop VR
      2. Mobile VR
    3. The difference between virtual reality and augmented reality
    4. Applications versus games
    5. How virtual reality really works
      1. Stereoscopic 3D viewing
      2. Head tracking
    6. Types of VR experiences
    7. Technical skills that are important to VR
    8. What this book covers
      1. Who are you?
    9. Summary
  8. Content, Objects, and Scale
    1. Getting started with Unity
      1. Creating a new Unity project
      2. The Unity editor
      3. The default world space
    2. Creating a simple diorama
      1. Adding a cube
      2. Adding a plane
      3. Adding a sphere and some material
      4. Changing the scene view
      5. Adding a photo
      6. Coloring the ground plane
    3. Measurement tools
      1. Keeping a unit cube handy
      2. Using a Grid Projector
      3. Measuring the Ethan character
    4. Using third-party content
    5. Creating 3D content with Blender
      1. An introduction to Blender
      2. A unit cube
      3. UV Texture image
      4. Importing into Unity
      5. A few observations
    6. Creating 3D content in VR
      1. Exporting and importing Tilt Brush models
      2. Publishing and importing using Google Poly
    7. Editing Unity in VR with EditorXR
      1. Setting up EditorXR
      2. Using EditorXR
    8. Summary
  9. VR Build and Run
    1. Unity VR Support and Toolkits
      1. Unity's built-in VR support
      2. Device-specific toolkits
      3. Application toolkits
      4. Web and JavaScript-based VR
      5. 3D worlds
    2. Enabling Virtual Reality for your platform
      1. Setting your target platform
      2. Setting your XR SDK
      3. Installing your device toolkit
      4. Creating the MeMyselfEye player prefab
    3. Building for SteamVR
    4. Building for Oculus Rift
    5. Building for Windows Immersive MR
      1. Setting up Windows 10 Developer mode
      2. Installing UWP support in Visual Studio
      3. UWP build
    6. Setting up for Android devices
      1. Installing the Java Development Kit (JDK)
      2. Installing Android SDK
      3. Via Command Line Tools
      4. About your Android SDK root path location
      5. Installing USB device debugging and connection
      6. Configuring the Unity External Tools
      7. Configuring Unity Player Settings for Android
    7. Building for GearVR and Oculus Go
    8. Building for Google VR
      1. Google Daydream
      2. Google Cardboard
      3. Google VR Play Mode
    9. Setting up for iOS devices
      1. Have an Apple ID
      2. Install Xcode
      3. Configuring the Unity Player Settings for iOS 
      4. Build And Run
    10. Summary
  10. Gaze-Based Control
    1. Ethan, the walker
      1. Artificially intelligent Ethan
      2. The NavMesh bakery
      3. A random walker in the town
      4. The RandomPosition script
      5. "Zombie-ize" Ethan!
    2. Go where I'm looking
      1. The LookMoveTo script
      2. Adding a feedback cursor
      3. Observing through obstacles
    3. If looks could kill
      1. The KillTarget script
      2. Adding particle effects
      3. Cleaning up
    4. Short intro to Unity C# programming
    5. Summary
  11. Handy Interactables
    1. Setting up the scene
      1. Creating a balloon
      2. Making it a prefab
    2. Basic button input
      1. Using the Fire1 button
      2. OpenVR trigger button
      3. Daydream controller clicks
    3. Polling for clicks
      1. Our own button interface functions
      2. Creating and releasing balloons
      3. Inflating a balloon while pressed
    4. Using scriptable objects for input
      1. Creating the scriptable object
      2. Populating the input action object
      3. Accessing the input action object
      4. Simulation testing with scriptable objects
    5. Using Unity events for input
      1. Invoking our input action events
      2. Subscribing to input events
    6. Really using your hands
      1. Parenting balloons to your hand
      2. Popping balloons
    7. Interactable items
      1. Interactables using SteamVR Interaction System
      2. Interactables using Daydream VR Elements
    8. Summary
  12. World Space UI
    1. Studying VR design principles
    2. A reusable default canvas
    3. Visor HUD
    4. The reticle cursor
    5. The windshield HUD
    6. The game element UI
    7. Using TextMeshPro
    8. Info bubble
    9. An in-game dashboard with input events
      1. Creating a dashboard with buttons
      2. Linking the water hose to the buttons
      3. Activating buttons from the script
      4. Look to highlight a button
      5. Looking and then clicking to select
      6. Looking and starting to select
    10. Pointing and clicking with VR components
      1. Using Unity UI and SteamVR
      2. Using Unity UI and Daydream
    11. Building a wrist-based menu palette
    12. Summary
  13. Locomotion and Comfort
    1. Understanding Unity characters
      1. Unity components
        1. The Camera component
        2. The Rigidbody component
        3. The Character Controller component
      2. Unity Standard Assets
        1. ThirdPersonController
        2. AIThirdPersonController
        3. First-person FPSController
        4. RigidBodyFPSController
    2. Using glide locomotion
      1. Move in the direction you're looking
      2. Keep your feet on the ground
      3. Don't pass through solid objects
      4. Don't fall off the edge of the world
      5. Stepping over small objects and handling uneven terrain
      6. Starting and stopping movement
    3. Adding comfort mode locomotion
      1. Other locomotion considerations
    4. Techniques for teleportation
      1. Looking to teleport
      2. Teleporting between surfaces
      3. Teleport spawn points
      4. Other teleport considerations
    5. Teleportation toolkits
      1. Teleporting with SteamVR Interaction System
      2. Teleporting with Daydream Elements
    6. Resetting center and position 
      1. Supporting room scale teleportation
    7. Managing VR motion sickness
    8. Summary
  14. Playing with Physics and Fire
    1. Unity physics
    2. Bouncy balls
    3. Managing game objects
      1. Destroying fallen objects
      2. Setting a limited lifetime
      3. Implementing an object pool
    4. Headshot game
    5. Paddle ball game
      1. Deflector versus paddle
    6. Shooter ball game
    7. Juicing the scene
      1. Great balls of fire
      2. Skull environment
      3. Audio synchronization
    8. Summary
  15. Exploring Interactive Spaces
    1. Level design with Blender
      1. Defining the walls
      2. Adding a ceiling
    2. Assembling the scene in Unity
      1. The gallery room level
      2. The artwork rig
      3. The exhibition plan
    3. Adding pictures to the gallery
    4. Managing art info data 
      1. Using lists
      2. Using data structures
      3. Using scriptable objects
    5. Displaying the art info
      1. Creating the title plaque
      2. Interactive info details
      3. Adjusting for image aspect ratio
    6. Moving around the gallery
      1. Teleporting between pictures
        1. Teleporting with SteamVR Interaction System
        2. Teleporting with Daydream Elements
      2. Room-scale considerations
      3. Animating a ride-through
    7. Summary
  16. Using All 360 Degrees
    1. 360-degree media
      1. Equirectangular projections
      2. VR is hacking your field of view
      3. 180-degree media
      4. Stereo 360-degree media
    2. Fun with photo globes
      1. Crystal balls
      2. Globes
    3. Rendering photospheres
      1. Writing a custom Inward shader
      2. Magic orbs
      3. Photospheres
      4. Playing 360-degree videos
    4. Using Unity skyboxes
      1. Six-sided or cubemap skyboxes
      2. Spherical panoramic skyboxes 
      3. 360 video skyboxes
      4. 3D stereo skyboxes
    5. Capturing 360-degrees in Unity
      1. Capturing cubemaps and reflection probes
      2. Using a third-party package for 360 image capture
      3. Unity built-in stereo 360 image and video capture 
    6. Summary
  17. Animation and VR Storytelling
    1. Composing our story 
      1. Gathering the assets
      2. Creating the initial scene
    2. Timelines and Audio tracks
    3. Using a Timeline to activate objects
    4. Recording an Animation Track
      1. A growing tree
      2. A growing bird
    5. Using the Animation editor
      1. A wafting nest
    6. Animating other properties
      1. Animating lights
      2. Animating a scripted component property
      3. Controlling particle systems
    7. Using Animation clips
      1. Shaking an egg
    8. Using Animator Controllers
      1. Definitions for Animation and Animator
      2. ThirdPersonController Animator
      3. Living Birds Animator
      4. Learning to fly
      5. Hacking the birds
      6. Fly away!
    9. Making the story interactive
      1. Look to play
      2. Resetting the initial scene setup
      3. More interactivity ideas
    10. Summary
  18. Social VR Metaverse
    1. Multiplayer networking
      1. Networking services
      2. The network architecture
      3. Local versus server
      4. The Unity networking system
    2. Setting up a simple scene
      1. Creating a scene environment
      2. Creating an Avatar head
    3. Adding multiplayer networking
      1. Network Manager and HUD
      2. Network Identity and sync Transform
      3. Running as a host
      4. Adding spawn positions
      5. Running two instances of the game
      6. Associating Avatar with the first-person character
    4. Adding a matchmaking lobby
    5. Syncing objects and properties
      1. Setting up the headshot ball game
      2. Spawning the ball over the network
      3. Synchronizing the ball transform
      4. State variable synchronization
    6. Advanced networking topics
    7. Options for voice chat
    8. Using Oculus platform and avatars
      1. Oculus platform entitlement check
      2. Adding a local avatar
      3. Adding remote avatars
    9. Building and sharing custom VRChat rooms
      1. Preparing and building the world
    10. Summary
  19. Optimizing for Performance and Comfort
    1. Using the Unity Profiler and Stats
      1. The Stats window
      2. Overview of the Profiler
    2. Optimizing your art
      1. Setting up the scene
      2. Decimating models
      3. Transparent materials
      4. Levels of detail
    3. Optimizing your scene with static objects
      1. Setting up the scene
      2. Lighting and baking
      3. Occlusion culling
    4. Optimizing your code
      1. Understanding the Unity life cycle
      2. Writing efficient code
      3. Avoiding expensive API calls
    5. Optimizing the rendering
      1. Life's a batch
      2. Multipass pixel filling
      3. VR-optimized shaders
    6. Runtime performance and debugging
      1. Daydream
      2. Oculus
    7. Summary
  20. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think