
Unity 5.x By Example
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
Key Features
[*]The most updated resource on Unity 5.x with comprehensive discussion on all the new features of Unity 5.x
[*]Understand the core concepts surrounding Unity5 game development with this power-packed hands-on guide
[*]Brush up your existing game development skills and create games that have a brilliant gameplay using the excellent examples from this book
Book DescriptionUnity is an exciting and popular engine in the game industry. Throughout this book, you'll learn how to use Unity by making four fun game projects, from shooters and platformers to exploration and adventure games. Unity 5 By Example is an easy-to-follow guide for quickly learning how to use Unity in practical context, step by step, by making real-world game projects. Even if you have no previous experience of Unity, this book will help you understand the toolset in depth. You'll learn how to create a time-critical collection game, a twin-stick space shooter, a platformer, and an action-fest game with intelligent enemies. In clear and accessible prose, this book will present you with step-by-step tutorials for making four interesting games in Unity 5 and explain all the fundamental concepts along the way. Starting from the ground up and moving toward an intermediate level, this book will help you establish a strong foundation in making games with Unity 5. What you will learn
[*] Understand core Unity concepts, such as game objects, components, and scenes
[*]Learn level design techniques for building immersive and interesting worlds
[*] Learn to make functional games with C# scripting
[*]Use the toolset creatively to build games of different themes and styles
[*]Learn to handle player controls and input functionality
[*]Dive into the process of working with terrains and world-creation tools
[*]Import custom content into Unity from third-party tools, such as Maya and Blender
[*]Get to grips with making both 2D and 3D games
Who this book is forThe ideal target audience for this book would be game developers. They need not have previous experience with Unity since this book will cover all the basics about game development with unity. This would also be a very good resource for Unity developers who want to brush up their basic Unity skills and also get up and running with creating interesting games with Unity 5.x.
All prices
More details
Other editions
Additional editions

Person
Alan Thorn is a multidisciplinary game developer, author, and educator with 16 years of industry experience. He makes games for PC desktop, mobile, and VR. He founded 'Wax Lyrical Games' and created the award-winning game Baron Wittard: Nemesis of Ragnarok, working as a designer, programmer, and artist. He has written 20 technical books on game development and presented fifteen video training courses. These cover gameplay programming, Unity development, 3D modelling, and animation. He has worked in game development education as a visiting lecturer for the National Film and Television School, as a lead teacher for Uppingham School, and as a senior lecturer at Teesside University.
Content
The Coin Collection Game: Part 1
Project A: The Collection Game Continued
Project B: The Space Shooter
Continuing the Space Shooter
Project C: 2D Adventure
Continuing the 2D Adventure
Project D: Intelligent Enemies
Continuing with Intelligent Enemies
Play testing and the Game tab
The environment created thus far for the coin collection game has been assembled using only the mesh assets included with the native Prototyping package. My environment, as shown in Figure 1.40, features two main floor islands with houses, and the islands themselves are connected together by a stepping-stone bridge. Your version may be slightly different, and that's fine.
Figure 1.40: The scene created so far contains two island areas
Overall, the scene is good work. It's well worth saving. To save the scene, press Ctrl + S on the keyboard or else choose File | Save Scene from the application menu. See Figure 1.41. If you're saving the scene for the first time, Unity displays a pop-up Save dialog, prompting you to name the scene descriptively (I called it Level_01).
Figure 1.41: Saving a scene
After saving the scene, it becomes scene asset of the project and appears in the Project panel. See Figure 1.42. This means that the scene is now a genuine and integral part of the project and not just a temporary work-in-progress as it was before. Notice also that saving a scene is conceptually different from saving a project. For example, the application menu has entries for Save Scene and Save Project. Remember, a Project is a collection of files and folders, including assets and scenes. A scene, by contrast, is one asset within the project and represents a complete 3D map that may be populated by other assets, such as meshes, textures, and sounds. Thus, saving a project saves the configuration between files and assets, including scenes. Saving a scene, in contrast, just retains the level changes within that specified scene.
Figure 1.42: Saved scenes are added as assets within your project
Tip
You can see from Figure 1.42 that I've saved my scene in a folder named Scenes. Folders can be created in your project by right-clicking on any empty area in the Project panel and choosing New Folder from the context menu, or else choose Assets | Create | Folder from the application menu. You can easily move and rearrange assets among folders by simply dragging and dropping them.
Now, the level, as it stands, contains nothing really playable. It's simply a static, lifeless, and non-interactive 3D environment made using the Editor tools. Let's correct this by making our scene playable, allowing the player to wander around and explore the world in first-person mode, controlled using the standard WASD keys on the keyboard. To achieve this, we'll add a first-person character controller to the scene. This is a ready-made asset included with Unity, which contains everything necessary to create quick and effective first-person controls. Open the Standard Assets | Characters | FirstPersonCharacter | Prefabs folder. Then drag and drop the FPSController asset from the Project panel in the scene. See Figure 1.43:
Figure 1.43: Adding an FPSController to the scene
After adding the first-person controller, click on the play button from the Unity toolbar to play test the game in first-person mode. See Figure 1.44:
Figure 1.44: Unity scenes can be play tested by clicking on the play button from the toolbar
On clicking play, Unity typically switches from the Scene tab to the Game tab. As we've seen, the Scene tab is a director's-eye view of the active scene; it's where a scene is edited, crafted, and designed. In contrast, the Game tab is where the active scene is played and tested from the perspective of the gamer. From this view, the scene is displayed through the main game camera. While play mode is active, you can play test your game using the default game controls, provided that the Game tab is in focus. The first-person controller uses the WASD keys on the keyboard and mouse movement controls head orientation. See Figure 1.45:
Figure 1.45: Play testing levels in the Game tab
Tip
You can switch back to the Scene tab while in play mode. You can even edit the scene and change, move, and delete objects there too! However, any and all scene changes made during play mode will automatically revert back to their original settings when play mode ends. This behavior is intentional. It lets you edit properties during gameplay to observe their effects and debug any issues without permanently changing the scene.
Congratulations! Your level should now be walkable in first-person mode. When completed, you can easily stop playback by clicking on the play button again or by pressing Ctrl + P on the keyboard. Doing this will return you to the Scene tab.
Tip
Unity also features a Toggle-Pause button to suspend and resume gameplay.
You should notice that, on playing the level with a first-person controller, you receive an information message printed to the Console window. By default, this window appears at the bottom of the Unity Editor, docked beside the Project panel. This window is also accessible manually from the application menu, Window | Console. The Console window is where all encountered errors or warnings are displayed for your review as well as information messages. Errors are printed in red and warnings in yellow, and information messages appear as a default grey. Sometimes, a message appears just once, or sometimes it appears many times repeatedly. See Figure 1.46:
Figure 1.46: The Console outputs information, warnings, and errors
As mentioned, the Console window outputs three distinct types of message: information, warnings, and errors. Information messages are typically Unity's way of making best practice recommendations or suggestions based on how your project is currently working. Warnings are slightly more serious and represent problems either in your code or scene, which (if not corrected) could result in unexpected behaviors and suboptimal performance. Finally, errors describe areas in your scene or code that require careful and immediate attention. Sometimes, errors will prevent your game from working altogether and sometimes errors happen at runtime and can result in game crashes or freezes. The Console window, therefore, is helpful because it helps us debug and address issues with our games. Figure 1.46 has identified an issue concerning duplicated audio listeners.
An audio listener is a component attached to a camera object. Specifically, each and every camera, by default, has an audio listener component attached. This represents an ear point, that is, the ability to hear sound within the scene from the position of the camera. Unfortunately, Unity doesn't support multiple active audio listeners in the same scene, which means that you can only hear audio from one place at any one time. This problem happens because our scene now contains two cameras, one that was added automatically when the scene was created, and the other that is included in the first-person controller. To confirm this, select the first-person controller object in the Hierarchy panel and click on the triangle icon beside its name to reveal more objects underneath, which are part of the first-person controller. See Figure 1.47:
Figure 1.47: Finding the camera on a first-person controller
Select the FirstPersonCharacter object, which is underneath the FPSController object (as shown in Figure 1.47). The FirstPersonCharacter object is a child of the FPSController, which is the parent. This is because FPSController contains or encloses the FirstPersonCharacter object in the Hierarchy panel. Child objects inherit the transformations of their parents. This means that as parent objects move and rotate, all transformations will cascade downwards to all children. From the Object Inspector, you can see that the object has an Audio Listener component. See Figure 1.48:
Figure 1.48: The FirstPersonController object contains an...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.
File format: PDF
Copy-Protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (only limited: Kindle).
The file format PDF always displays a book page identically on any hardware. This makes PDF suitable for complex layouts such as those used in textbooks and reference books (images, tables, columns, footnotes). Unfortunately, on the small screens of e-readers or smartphones, PDFs are rather annoying, requiring too much scrolling.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our eBook Help page.