Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Build a 3d Virtual Reality Whackamole Game
Build a 3d Virtual Reality Whackamole Game
Build a 3d Virtual Reality Whackamole Game
Ebook463 pages2 hours

Build a 3d Virtual Reality Whackamole Game

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Learn to create the art and code for a 3D virtual reality (VR) Whackamole game. In this eBook, we take you through each step of game development, from downloading software to integrating art.

The programs we use are Unity and Blender, the top free platforms for building VR games. We create real examples that you can follow along with as you learn.

This eBook is an extension of Mammoth Interactive's "Introduction to Unity" book. In Part 1, you learn how navigate the Unity Editor, set up scenes, and make game objects. We make a 2D game where a player shoots a bullet at a wall to trigger an explosion.

In Part 2, you learn how to customize the appearance and behavior of objects using C# scripts by building a 3D shooter game.

In Part 3, we build a Whackamole game from scratch. We use Blender to make our art assets and 3D models. By the end of this eBook, you have a fully-functioning 3D VR game that you can put in your portfolio.
LanguageEnglish
PublisherLulu.com
Release dateApr 3, 2017
ISBN9781365869563
Build a 3d Virtual Reality Whackamole Game

Read more from John Bura

Related to Build a 3d Virtual Reality Whackamole Game

Related ebooks

Computers For You

View More

Related articles

Reviews for Build a 3d Virtual Reality Whackamole Game

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Build a 3d Virtual Reality Whackamole Game - John Bura

    Build a 3d Virtual Reality Whackamole Game

    Build a 3D Virtual Reality Whackamole Game

    by John Bura, Alexandra Kropova, Kevin Liao, and Glauco Pires

    Copyright

    © 2017 Mammoth Interactive, Inc. All rights reserved.

    ISBN 978-1-365-86956-3

    Printed in Canada.

    Published by Mammoth Interactive, Inc., 218 – 111 West Broadway, Vancouver, British Columbia, Canada V5Y 1P4.

    Mammoth Interactive books may be purchased for educational, business, or sales promotional use.

    Content Creators: John Bura, Kevin Liao, and Glauco Pires

    Transcriber/Editor: Alexandra Kropova

    April 2017: First Edition

    About the Author

    When game enthusiast John Bura wanted to learn game development back in 2009, he could not find any classes to take. So he purchased a DVD set and learned that way. He learned how to build a game with an efficiency he had never seen in any of his university classes.

    John felt compelled to share his new-found enthusiasm for this self-guided approach to learning. He founded Mammoth Interactive, with the goal that he would take online education to the next level. And so evolved Mammoth Interactive's holistic approach to teaching that did not just aim at someone who wanted to fine-tune their skills.

    John's goal was to teach everyone, from your eight-year-old cousin to your eighty-year-old grandparent. Anyone can be a game developer. All that jargon can be replaced with practical, useful projects that students create alongside the instructor.

    Since 2009, over 300,000 students have enrolled in Mammoth Interactive. And they love it. Go to www.mammothinteractive.com to get free stuff, courses, books, apps, games, t-shirts, daily deals, and more!

    www.mammothinteractive.com

    Introduction

    In this book, you will learn how to build the art and code for a 3D virtual reality Whackamole game. The first part of this book is an introduction to Unity for those who have never used it before. Unity is the Number One free program for building virtual reality (VR) games. You will learn how to set up a scene, add objects, and change the appearance of your game in Unity. You will also learn how to import packages from the Asset Store.

    In Part Two, you will learn how to use the C# programming language to create scripts for your games. Thus you will be able to customize the behavior and appearance of your game objects.

    In Part Three, we will build a fully-functioning Whackamole game from scratch. You will learn how to build the art and code for the game. We will use Blender to make our art assets and 3D models. Blender is a free modeling tool. We will integrate our high-quality art from Blender into our game in Unity.

    By the end of this book, you will have a Whackamole game that you can show off in your portfolio. Ready to begin?

    Part 1: Unity Editor 5

    If you want to make a VR game, Unity is the program for you. The Unity engine comes with built-in models, materials, and more, which you can use to make your own 2D or 3D games.

    Unity is the most popular platform for building VR games. You can build a variety of 2D and 3D games with its user-friendly interface.

    In Part One, we will cover features of the Unity engine. We will look at 3D models, simple shapes like cubes and spheres. We will look at how to navigate throughout a scene, add shapes, and change appearances.

    Chapter 1: Downloading Unity

    To download Unity, visit www.unity3d.com. On the homepage, press the button Get Unity now.

    You will be taken to a page containing versions of Unity that you can download. The Personal version is free. You can publish games to the App Store with this version. Click on the Download Now button in the Personal bar.

    Press Download Installer, which will download the helper file UnityDownloaderAssistant. Double-click the file, and open the Unity Download Assistant file that appears.

    Press the Open button from the pop-up that appears. Then press Continue from the installation instructions. Read the terms of service, and press Continue and Agree if you agree with them.

    Then you will see options on which Unity components you wish to download. Ensure that the top three items are selected (Unity 5.4.3f1, Documentation, and Standard Assets). You can select additional components to install extra files.

    Press Continue. Once the files are installed, you can open Unity!

    Chapter 2: Introduction to Unity

    To make a new project in Unity, click on NEW in the top right of Unity's start screen.

    In the start screen, you can adjust some of the project's settings.

    Give the project a name and location. The Location field refers to the folder in which you want to save the project. It is good practice to create a new folder just for your Unity projects so that you can easily find them.

    Have the 3D rendering mode enabled. Press the Create Project button. Unity will create a folder with the same name as your project name in the location you specified.

    The Unity Editor will open. Your screen will look like the following:

    The left sidebar is the Hierarchy window. This is like the hierarchy you have in your operating system. For example, in your Pictures folder, you may have sub-folders of events that group together photos.

    The Hierarchy lists the names of the objects in the game's scene. Each object can have its own hierarchy. Currently, we have the items Main Camera and Directional Light, which are game objects. Anything that changes how a game works visually or internally, such as a player, enemy, or explosion, should be in a game object.

    You can see the objects listed in the Hierarchy in the Scene window, which is the window in the center of your screen. The Scene displays the virtual world you build for a game.

    Right-click in the Scene window. The cursor will change to an icon of an eye, as evident in the next image. While holding the right mouse button, you can move the cursor to look around the Scene.

    Another way to navigate the Scene is to press the W, A, S, and D keys on your keyboard while holding the right mouse button. This is like the left, right, forward, and back arrow controls on a video game handheld.

    Click on Main Camera in the Hierarchy. Arrows will appear around the camera symbol in the Scene.

    The Main Camera renders (draws) the game for the player. It can be thought of as a player. While Main Camera is selected, there is a Camera Preview box in the bottom right of the scene. The Camera Preview shows the scene from the perspective of a player.

    To see the scene from a player's point of view, click on the Game tab beside the Scene tab. The Game window will open, as in the following screenshot.

    Re-open the Scene window. Click on Directional Light in the Hierarchy. Arrows will appear around the Directional Light's symbol in the Scene. The Directional Light emits light rays. You can change this game object to change the lighting of a scene.

    The window to the right of the Scene contains the Inspector. This window shows details of a selected item, such as a game object in the Scene or a file in our project.

    Click on Main Camera. The Inspector will fill with attributes of Main Camera that you can change. At the top is the name of the game object.

    The Tag tab allows you to label the object. The Layer tab is not often changed for Main Camera because this tab can help you check for collisions in the scene.

    Main Camera's Inspector shows the following components: Transform, Camera, GUI Layer, Flare Layer, and Audio Listener. Components change how game objects behave.

    The Transform component is the most basic component of a game object. Transform allows you to set the position, rotation, and scale of an object.

    The Camera component shows details about the camera. Currently, the Clear Flags property is Skybox, so the Game Window contains a sky. If you change Clear Flags to Solid Color, the Game window will fill with the color of the Background property.

    A lot of learning in Unity is experimentation; changing values and seeing the immediate effects in the Game window.

    Select Directional Light from the Hierarchy. The Inspector will change to contain components of the Directional Light object. In the Light component, you can change the light's type, color, intensity, shadows, and more.

    The bottom window in Unity contains the Project window. This window contains the Assets folder, which contains all the files that make up your game. Any 3D models, scripts, materials, animations, sound clips, video files will be in Assets.

    Beside the Project tab is the Console tab. Note that if Console is not enabled beside Project on your screen, go to Unity > Window > Console.

    The console displays messages to you as the developer. Three kinds of messages can appear:

    Error messages- coloredred; icon is an octagon.Error messages can appear when there is a mistake in your code or when a plug-in is not working.

    Warning messages- colored red; icon is a triangle.Warnings can provide suggestions that improve your code.

    Basic information messages- colored white or black; icon is a speech bubble. In your game's code, you can set messages to print in the console. These messages can inform you of whatis happening in the game so that you know whether the game is behaving properly.

    Those are the main windows that make up the Unity editor. In the next section, we will use several of these windows to add elements to our scene.

    Chapter 3: Transforming Objects

    As mentioned in the previous section, there is a component that is in nearly all game objects in Unity: Transform.

    Select Main Camera from the Hierarchy. To change the camera's X position in the Scene, you can change the 0 in the X field of the Position property. For instance, change Main Camera's X position to 2, as in the following screenshot. The camera will move in the Scene.

    Another way to change the X position is to click on the X beside Position and drag your cursor left and right.

    Notice that changing the X position moves the camera in one degree of freedom: along the horizontal axis. The horizontal axis is represented as the red arrow extending from the camera in the Scene. You can click on this red arrow to move the camera horizontally.

    The gizmo at the top right of the Scene window shows that the red arrow pertains to the X axis.

    The Y position represents the vertical axis. Changing the Y position in the Transform component moves the camera up and down.

    The X and Y positions allow us to put the camera in a 2D environment. The Z position, which represents the depth axis, creates a 3D environment. Changing the Z position moves the camera forward and back.

    Zoom in on Main Camera in the Scene. Three rectangles are on top of the camera's icon.

    You can click and drag the rectangles to move the camera in different planes. For example, the green rectangle moves the camera in the XZ plane.

    The Rotation property in the Transform component works similarly to Position. Changing the X Rotation makes the camera look up and down. Changing the Y Rotation makes the camera look left and right. Changing the Z Position rotates the camera sideways, as though a player were tilting their head to the left and right.

    There is another way to change Rotation. In the top left of the Unity window, there are several icons that pertain to available tools. The first tool moves the developer camera. This tool is an alternative to holding the right mouse button.

    The second tool, which is pre-selected by default, allows you to move objects. Clicking on the third icon changes the tools around the Main Camera, as evident in the next image. Instead of arrows, there will be a red circle, green circle, and blue circle.

    If you click and drag the circles, the camera will rotate. The colors correspond to the different axes: red for X, green for Y, blue for Z. If you click on the sphere between the circles, you can rotate the camera in all three axes.

    The third element in the Transform component is Scale, which also has X, Y, and Z values. Scale changes the size of an object. Note that if you change the Scale values for Main Camera, the camera's size will not change. This is because the camera icon is not rendered in the game. The icon represents the player's point of view.

    The directional light is also an abstract. The player will not see its icon. Thus Scale will not work on these objects. However, Scale will change the size of a 3D element.

    To prototype a game in Unity, you can design a scene using primitives. There are several primitives, or elements, that you can create in Unity, such as a cube.

    To make a 3D element, right-click in the Hierarchy. A menu will appear containing listing game objects you can create. Clicking Create Empty would create a net game object, which has only a Transform component.

    In the "3D

    Enjoying the preview?
    Page 1 of 1