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

You're reading from  Unity Virtual Reality Projects

Product type Book
Published in Sep 2015
Publisher Packt
ISBN-13 9781783988556
Pages 286 pages
Edition 1st Edition
Languages
Author (1):
Jonathan Linowes Jonathan Linowes
Profile icon Jonathan Linowes

Table of Contents (18) Chapters

Unity Virtual Reality Projects
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Virtually Everything for Everyone Objects and Scale VR Build and Run Gaze-based Control World Space UI First-person Character Physics and the Environment Walk-throughs and Rendering Using All 360 Degrees Social VR Metaverse What's Next?
Index

Chapter 6. First-person Character

Ninja on Segway illustration by Alaric Holloway, used with permission

Surprisingly, we have gotten this far in a book about VR and are still only using a fixed position third-person camera! This was intentional.

The typical approach when one starts to build a VR application is to immediately place the user directly into the scene as a first-person character. After all, wearing a VR headset is inherently a first-person point of view. However, virtual reality does not always need to be from a first-person perspective. Watching and controlling the action from a third-person point of view, such as a diorama with live actors, is a legitimate approach. In fact, some research indicates that fast-paced action games, which can unavoidably cause motion sickness when played in VR from a first-person point of view, may benefit from a third-person perspective instead.

That said, in this chapter, we will now move ourselves into a controllable first-person character and explore...

Understanding the Unity characters


A first-person character is such a key asset in a VR project that we really should understand its components inside out. So, before we go about building one for our project, it would be a good idea to take a close look at the built-in components and standard assets that Unity provides.

Unity components

As you probably know, each Unity game object contains a set of associated components. Unity includes many types of built-in components, which you can see by browsing the Component menu in the main menu bar. Each component adds properties and behaviors to the object that it belongs to. A component's properties are accessible via the Unity editor's Inspector panel and scripts. A script attached to a game object is also a type of component, and may have properties that you can set in the Inspector panel.

The component types used to implement first-person characters include the Camera, Character Controller, and/or Rigidbody, and various scripts. Let's review each...

Making a first person


For making a first person feature, let's take an agile approach to development. This means (in part) that we'll start by defining our new feature, or story, with a set of requirements. Then, we'll incrementally build and test this feature, one requirement at a time, by iterating and refining our work as we go along. Experimentation is not only allowed, it's encouraged.

Note

Agile software development is a broad term for methodologies that encourage small incremental and iterative developments in a fashion that's easy to respond to the changing and refined requirements.

Feature: As a first-person character, when I start walking, I will move through the scene in the direction I am looking until I indicate to stop walking.

Here are the requirements to achieve this feature:

  • Move in the direction you're looking

  • Keep your feet on the ground

  • Don't pass through solid objects

  • Don't fall off the edge of the world

  • Step over small objects and handle uneven terrain

  • Start and stop moving...

User calibrations


How tall are you? Are you presently sitting or standing? Am I referring to your real-life human self or your player inside the virtual world? Your first-person VR experience may not feel right if your virtual self isn't calibrated.

Mind you, I am not referring to your VR headset's physical configurations. For example, Oculus Configuration Utility lets you calibrate the settings for eye relief (how far the HMD lenses are from your eyes) and Interpupillary Distance (IPD) (distance between your eyes), which affect the low-level distortion rendering that is performed by the SDK drivers. Although those may be important to have a satisfactory experience, I'm referring to calibrating the in-game character in the scene with you—the player.

A character's height

I do not know whether you've been paying much attention to the first-person camera height, but it appears that we shrunk recently. Before this chapter, the eye-level of the camera was set to be eye-to-eye with Ethan. Now, we...

Maintaining a sense of self


In VR, you could just be a floating one-dimensional eyeball in virtual space (like our initial Diorama camera), a normal human being, or maybe some full-bodied space creature. We have focused on walking around the scene and discussed how to set the camera height to the eye level. The implication was that someone experiencing VR has a sense of their own body. However, the camera height actually only makes sense when there's also a ground plane or some other stable reference point in your vicinity. When you're flying around like a bird, plane, or Superman, then the body height may not matter much.

Yet in the physical world, we all really do have bodies, and our brains kind of expect that. Issues surrounding the sense of self can get very psychological, philosophical, and even religious. Also, it's mind-bending what VR might eventually be able to do in this regard. For now, we should focus on what we need in order to help make our VR experiences comfortable for our...

Locomotion, teleportation, and sensors


We just implemented a simple look-based mechanism to move through a virtual reality scene. You could of course decide to stick with a keyboard, joystick, or a gamepad to control your character like a conventional video game. New techniques for locomotion and teleportation control are continuously being tried. Here are some ideas:

  • Look to walk: Walk in the direction of your gaze. Your feet stay on the ground, animated. This is the mechanism that we previously implemented.

  • The hover disc: Step onto a hover disc to begin moving. Step off it when you're done. This requires a way to indicate the action of stepping on and stepping off.

  • Segway: Like the hover disc but you move forward and turn by leaning into it, and slow down or stop by leaning back.

  • The Superman fly: Jump to take off, fly by looking, and crouch to land. With positional hand controllers, you can stretch your hands out to your sides to glide and in front to go up or down. Also, take off by...

Managing VR motion sickness


VR motion sickness, or simulator sickness, is a real symptom and a concern for virtual reality. Researchers, psychologists, and technologists with a wide array of specializations and PhDs are studying the problem to better understand the underlying causes and find solutions.

A cause of VR motion sickness is a lag in screen updates, or latency, when you're moving your head. Your brain expects the world around you to change exactly in sync. Any perceptible delay can make you feel uncomfortable, to say the least.

Latency can be reduced by faster rendering of each frame, keeping the recommended frames per second. Device manufacturers such as Oculus and others see this as their problem to solve, in both hardware and device-driver software. GPU and chip manufacturers see it as a processor performance and throughput problem. We will undoubtedly see leaps and bounds in improvements over the coming years.

At the same time, as VR developers, we need to be aware of latency...

Summary


In this chapter, we took a deep dive into what it means to have a first-person character in Unity and virtual reality. We started by dissecting the Characters prefabs under Unity's Standard Assets and the components that they use, including Camera, Character Controller, and/or Rigidbody.

Then, we developed our own first-person character, starting with the static positioned VR camera rig that we used for our Diorama scene. We incrementally added features to move in the direction of your gaze, gravity, solid-object collisions, and use head gestures to start and stop walking. We made adjustments for camera height and explored the relationship between a first-person head versus a body in virtual reality. Lastly, we reviewed some of the factors that VR developers should think about to provide a comfortable VR experience and avoid motion sickness.

It is not my intent to say that you should always build your own first-person controllers instead of using the prefabs provided by Unity or VR...

lock icon The rest of the chapter is locked
You have been reading a chapter from
Unity Virtual Reality Projects
Published in: Sep 2015 Publisher: Packt ISBN-13: 9781783988556
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 $15.99/month. Cancel anytime}