Unity Virtual Reality Projects
上QQ阅读APP看书,第一时间看更新

Ethan, the walker

Gaming is a common application of virtual reality. So, we might as well start out from there, too! We are going to give our character, Ethan, a life of his own. Well, sort of (or not), because he's going to become a zombie!

We left off at the diorama, with Ethan hanging out. You can make him run around the scene if you have a hand controller with a thumbstick or touchpad, but that is not guaranteed on some VR devices. In fact, if you're viewing the scene with a Google Cardboard, it's pretty unlikely that you'll have a handheld controller (notwithstanding the Bluetooth game controllers). In the next chapter, Chapter 5, Handy Interactables, we will go into handheld input controllers. For now, we will consider another way to make him move around, using the direction of your gaze while wearing your VR headset.

Before we attempt this, we'll first transform Ethan into a zombie and have him walk around aimlessly without any user control. We'll do this by giving him some AI and writing a script that sends him to random target locations.

AI controllers and NavMesh are somewhat advanced topics in Unity, but we're going to throw you into it just for fun. Besides, it's not as scary as zombies.