Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Enhancing Virtual Reality Experiences with Unity 2022

You're reading from  Enhancing Virtual Reality Experiences with Unity 2022

Product type Book
Published in Nov 2023
Publisher Packt
ISBN-13 9781804619537
Pages 566 pages
Edition 1st Edition
Languages
Author (1):
Steven Antonio Christian Steven Antonio Christian
Profile icon Steven Antonio Christian

Table of Contents (25) Chapters

Preface 1. Part 1: Philosophy and Basics of Understanding Virtual Reality
2. Chapter 1: Philosophy of Building Immersive Experiences 3. Part 2: Technical Skills for Building VR Experiences in Unity (Assets, GameObjects, Scripts, and Components)
4. Chapter 2: Building VR Scenes in Unity 5. Chapter 3: Working with Inputs and Interactions 6. Chapter 4: Using Game Objects, Materials, and Prefabs 7. Chapter 5: Implementing Animation – Physics and Colliders 8. Chapter 6: Lighting Your Worlds and Experiences 9. Chapter 7: Creating Immersion with Sound 10. Chapter 8: Working with C#, Unity Events, and Input Actions 11. Chapter 9: Unlocking the Power of Render Pipelines 12. Part 3: Projects: Putting Skills Together
13. Chapter 10: Design Thinking for Virtual Reality Experiences 14. Chapter 11: Adding Audio to a Virtual Reality World 15. Chapter 12: Building an Art Gallery 16. Chapter 13: Animating a Virtual Reality Experience 17. Chapter 14: Recording Virtual Reality Videos 18. Chapter 15: Enhancing Virtual Reality Rigs 19. Chapter 16: Triggering Actions in Virtual Reality 20. Chapter 17: Destroying Objects in Virtual Reality 21. Part 4: Final Touches
22. Chapter 18: Optimizing Your Virtual Reality Experiences 23. Index 24. Other Books You May Enjoy

Triggering Actions in Virtual Reality

We’ve ventured far and wide in the VR realm, from creating immersive environments to animating lifelike movements, and from mastering C# coding to understanding the Unity input system. Now, we’re ready to apply all these skills to design dynamic, interactive experiences in the VR world. In this chapter, we’ll focus on constructing a VR rig menu system to control various settings, using triggers to command animations, employing portals for seamless travel between the diverse scenes we’ve crafted, and harnessing the power of the physics system to create lively bouncing balls such as basketballs.

We will start by creating a VR settings menu that can control the different values we added for our VR rig abilities, including running, jumping, and crouching from Chapter 15. We will then move on to triggering our animations from the Adding animation clips to our timeline section of Chapter 13, enabling the animated experience...

Creating and configuring a VR settings menu

Settings menus are crucial for VR experiences and any experience made in Unity because if you’re not able to control the settings at runtime, you’re often stuck in developer mode instead of exploration mode. Quite often, you want to be able to modify different abilities within the VR world that don’t require you to take off the headset, and creating a VR settings menu allows you to do that. More importantly, you can add fun little elements that allow you to improve or obscure the VR experience, because modifying the way we navigate in the world is a whole experience in and of itself.

By the end of this section, you will have a VR settings menu that accesses the run, jump, and crouch abilities, and you can control those different abilities using sliders on a mini screen. We will attach this menu screen to a menu button on our left VR controller that we can toggle on and off easily with the press of a button. This whole...

Triggering animations in the scene

One of the best things about creating animations is that you can reuse the content you create over and over again. However, animations are often created just for videos and don’t exist anywhere else. This will change with VR, as we can now utilize the same animated assets we created for videos and experience them in VR. This is possible because VR uses real-time rendering, which allows us to walk around animated scenes and view them from any angle we desire. Triggering animated scenes is especially fun for animators and those interested in visual storytelling because it changes the way stories can be told and experienced.

In this section, we will cover how to reuse our collider controller script with a new collider that we can use as a portal. We will step into the portal and trigger the animation to play. When we step out of the portal, the animation will pause. This is a simple implementation, but it can be expanded on with multiple animated...

Adding portals for navigation

As we saw in the Creating portals with colliders and events section in Chapter 8, where we created our portals to move between different scenes and areas of our map, they are very powerful tools for navigation. If you want to go to the other side of an area or to a completely different location, such as walking into a building or walking out of a building, you can do that by walking into a portal and being placed exactly where you need to be.

We will use the portals we created in the Creating portals with colliders and events section in Chapter 8 and expand on them so that they can be used within our VR world, allowing us to bounce from one aspect of the VR experience to another. We will start by adding a portal to go to our art gallery. After we finish the art gallery, we will move on to the VR theater and then to the demo room scene that we worked on in the first half of this book. Essentially, we will put all of the scenes we’ve worked on...

Creating and controlling a bouncing basketball

Creating a bouncing ball requires a variety of different systems in Unity. Whether it’s the physics system, the C system, the scripting render pipeline, the animation system, or even the XR interaction toolkit, all of these things have to work together with your coordination in order to have a successfully bouncing ball that you can dribble down the sidewalk. This is a very simple implementation, but it’s very effective because through this, you can add different object-to-object interactions, and you can make them continuously and directly interact with objects using your hand controllers. Bouncing a ball may appear deceptively simple, yet in the realm of VR, it proves to be a challenging endeavor. As we strive to simulate real-world physics within the virtual realm, we come to appreciate the intricate coordination required to achieve realistic ball bouncing. Often taken for granted in reality, the interaction between objects...

Summary

The magic of VR truly comes alive as we bring in trigger interactions to animate our VR world. With a simple trigger, you can summon a VR menu, set off animated sequences, or even whisk yourself away through portals to different corners of your virtual universe. One of our more whimsical achievements was creating a bouncing basketball. As simple as a bouncing basketball sounds, this opens up numerous fun and interactive experiences for the user, enhancing their coordination and engagement with the VR world around them. At this point, your project may seem hefty, but think of it as a treasure trove of assets, ready for you to use and create experiences that would have otherwise taken much longer.

In the next chapter, we will conclude our projects by implementing a system to destroy virtual objects with projectiles, adding impact with various particle effects.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Enhancing Virtual Reality Experiences with Unity 2022
Published in: Nov 2023 Publisher: Packt ISBN-13: 9781804619537
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}