Reader small image

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

Product typeBook
Published inNov 2023
Reading LevelBeginner
PublisherPackt
ISBN-139781804619537
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Steven Antonio Christian
Steven Antonio Christian
author image
Steven Antonio Christian

Steven Christian is an Augmented Reality Developer, Animator, and Medical Student Student. He's also the Owner of Iltopia Studios where he creates comics and cartoons that explore the Black experience in America. He is Unity Certified 3D Artist and Instructor and his goal is to improve equity in arts and technology through content creation and community-focused education.
Read more about Steven Antonio Christian

Right arrow

Adding Audio to a Virtual Reality World

In this chapter, we will integrate many of the skills we learned in the previous sections to build our first project. Using the virtual world we created in the Experienced design section of Chapter 10, we will add spatial audio to populate our environment with interesting sounds, creating a fully immersive experience.

We will have environment sounds as well as 3D sounds in specific areas that accentuate what those areas represent. We’ll also set up ambient sounds and use this as a foundation to build on as we add more visuals and interactions in the next couple of chapters. By the end of this chapter, you will be able to walk around a virtual park, go for a hike, and change your audio experience according to your unique specifications.

We will cover three main sections in this chapter. These include adding park audio, adding audio sources and sounds to our car, and adding audio sources and sounds to our non-playable characters or...

Adding park audio

Since we spent so much time perfecting the visuals of our virtual world, it’s time to pay attention to the audio. Audio can make or break any experience because it is a significant component of how we experience entertainment and other things. Therefore, we have to pay close attention to creating an immersive experience, particularly within a park setting. There are many sounds reminiscent of the tranquil nature of a park, and having birds chirping and water running is something people are all too familiar with. Recreating these sounds in VR will help us achieve our desired immersive experience.

If you recall from the Roadmapping section of Chapter 10 where we talked about Phase 5 of our roadmap, we specifically planned in our sound design experience to add city environmental sounds, forest sounds, and water sounds to the lake. To follow this, we’ll add bird sounds to the tree areas and city sounds to the edge of the park. Finally, we’ll add...

Adding car audio

In Phase 5 of our roadmap, which we worked on in Chapter 10, we discussed adding environment sounds to our city. One of the ways we can do that is by adding sounds to cars because, primarily, environment sounds in a city are car sounds and people sounds. Since we have people sounds covered, we will focus on car sounds and how that environment can be built based on what we have already.

In this section, we will first focus on downloading our car audio sounds, and then we’ll move on to adding spatial audio to the car prototypes that we created. Finally, we’ll create a game manager script that allows us to control and vary car engine and honking sounds.

To add spatial audio to cars, follow these steps:

  1. Go to the Unity Asset Store and search for Engines: https://assetstore.unity.com/packages/audio/sound-fx/engines-123836.
  2. Download and import the ENGINES package, which contains audio files such as car engine and honking sounds.
  3. You will...

Adding NPC audio

As mentioned in the previous section, adding audio to our People_Prototype prefabs really allows us to have a wholesome experience because we can populate our scenes with people, and then when you walk close to them, you’ll be able to hear them talk about different things. We can utilize this within our VR experience so that it doesn’t sound dull and boring. We can download an asset that allows us to have a variety of different dialogues and voices in different tones. Then, we can randomize that and apply it to the different prefabs. Using an algorithm similar to the car audio, we can have an algorithm that generates audio randomly, based on the tone and voice that we choose, creating variability in the audio that comes from different people.

In this section, we will create an audio source for our People_Prototype prefab and use the downloaded voices to create a dialogue system that allows us to choose whether a person is angry, sad, happy, or glad...

Summary

This chapter covered a lot of material, focusing on Phase 5 of our roadmap document, where we built out the sound design for our VR world. We created some Park Audio and Audio Sources, and made different audio managers for each category, such as the park, car, or NPC, and added new elements to give each area unique sounds. This was an easy task because we had the option to use audio sources from the Unity Asset Store, and more importantly, we were able to take a systematic approach to build C# code that allows us to add variability to the sounds, timing, content, categories, and implementation.

Playing with C# code, the Unity Editor, and our creativity allowed us to create immersive experiences with VR that we could literally walk around and experience in real time. This concept of creativity and the freedom to implement different ideas speaks to the power of VR development. As a developer myself, I really enjoy it because it allows me to unlock my potential as a creator...

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 2023Publisher: PacktISBN-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.
undefined
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

Author (1)

author image
Steven Antonio Christian

Steven Christian is an Augmented Reality Developer, Animator, and Medical Student Student. He's also the Owner of Iltopia Studios where he creates comics and cartoons that explore the Black experience in America. He is Unity Certified 3D Artist and Instructor and his goal is to improve equity in arts and technology through content creation and community-focused education.
Read more about Steven Antonio Christian