Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Mastering Unity 2017 Game Development with C#
Mastering Unity 2017 Game Development with C#

Mastering Unity 2017 Game Development with C#: Create professional games with solid gameplay features and professional-grade workflow , Second Edition

Arrow left icon
Profile Icon Alan Thorn
Arrow right icon
zł39.99 zł177.99
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.5 (2 Ratings)
eBook Oct 2017 568 pages 2nd Edition
eBook
zł39.99 zł177.99
Paperback
zł221.99
Subscription
Free Trial
Arrow left icon
Profile Icon Alan Thorn
Arrow right icon
zł39.99 zł177.99
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.5 (2 Ratings)
eBook Oct 2017 568 pages 2nd Edition
eBook
zł39.99 zł177.99
Paperback
zł221.99
Subscription
Free Trial
eBook
zł39.99 zł177.99
Paperback
zł221.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Mastering Unity 2017 Game Development with C#

Level Design and Structure

This chapter is about designing and building playable levels for Dead Keys. More accurately, Dead Keys consists of multiple levels, and in this chapter, our focus will be on the creation of one of those levels in detail. Only one needs be considered because the level creation process is merely repeated creatively, after creating the first level, to produce all the remaining levels at increasing difficulty levels. By level, I mean a scene in Unity terms--a complete and integrated 3D world where the game evolves according to its internal rules and logic. We'll look, in depth, at using and reusing modular assets, such as environment meshes, to build interesting levels of any size needed; we'll also see lightmapping and lighting overall to enhance realism as well as NavMesh generation for artificial intelligence and Occlusion Culling for rendering...

Setting the scene with a skybox

Our game environment should be dark, creepy, and suspenseful. However, every new Unity scene is created with a default, procedural skybox representing a cheery daytime exterior; this needs to be changed. A skybox is ultimately a cube with a flipped normal that surround and encompass the environment. Its faces contain an environment texture which, when mapped correctly, appears seamlessly across the model, creating the look of a vast skyline surrounding the scene. The primary purpose of our skybox should be to set a base and ambient lighting. The most appropriate skybox for our usage, then, is a night skybox or, at least, a dark, stormy (and perhaps slightly alien) skybox. There are many ways to create a skybox in Unity. One method is to create a cube-map texture (six separate textures) inside the image-editing software that maps to the faces of...

Level building - Modular construction sets

Now the fun begins, though it's logistically challenging: the process of level building. Our aim is to build a fun and interesting level, but this must be balanced against many factors, including level size, ease of navigation, variety, and more. Creating a level is challenging because misplaced or poorly designed elements stand out for their failings. They break the player's experience. Decisions about architecture and where to include straight sections, turns, jumps, ledges, props, and doors collectively influence the atmosphere and mood of a level. Here, we'll focus on the modular building method, piecing together an expansive level from reusable pieces, exploring reasons and justifications for our choices along the way. However, let's first see the modular set in its entirety, that is, the complete collection of...

Level building - Organization and structure

Let's start the level construction process. There are many ways to begin here, but it's a good idea from the outset to develop with a clean workflow in mind. By clean, I mean an organized, structured, and easy-to-maintain workflow, one that remains maintainable for projects of many scales. First, delete any and all objects in the new scene, and then create a single empty GameObject named root by navigating to GameObject | Create Empty from the application menu. This object will be the topmost object in the hierarchy, from which everything else will be a child directly or indirectly:

Creating a root object for the scene

Next, create a new child object named env, which will contain all environment pieces. Ensure that both the root and env objects are positioned at the world origin at (0,0,0). I typically position the world floor...

Level design - Tips and tricks

Don't underestimate the design challenges faced when building a level. Arranging mesh modules meaningfully and constructing a layout that encourages exploration and invites interest is challenging. Is a corridor too long or too bendy? Is a walkway too narrow or too wide? Should there be a prop (such as a chair or a desk) in the corner of a room? These types of question, and others, matter! They're not the kinds of thing that should be settled just by flipping a coin. Consider the following design tips and tricks, which are some guiding principles intended to help you build more interesting levels more quickly and easily.

Objective and feedback

Always remember the player objective when...

Level lighting - Preparation

Reaching this far, you've now made a complete scene in terms of meshes representing the first level, composed of modular environment pieces (corridor sections). Presently, the level features no lighting, navigation meshes, music or audio, and Occlusion Data, but we'll add these soon. Let's start with lighting. In Unity, there are three main lighting types or systems, which exist on a spectrum:

  • Baked lighting
  • Real-time lighting
  • Precomputed global illumination

These are discussed in further detail here.

Baked lighting

Baked lighting is the optimal lighting method, but it can only be used under specific circumstances. With baked lighting, all lighting data (highlights, shadows, and...

Getting started with lightmapping

To start baking scene lighting, we'll first need to activate Lightmap UVs for the environment meshes and then position some lights in the scene where appropriate. To activate Lightmap UVs, select all environment meshes in the Project panel and enable Generate Lightmap UV from the object Inspector. Then, click on Apply. This method is useful for generating a second UV channel when one doesn't already exist. This defines how lighting is baked to the lightmap texture. Unity applies an autounwrap projection using settings from the Advanced roll out. If, by contrast, your own meshes already have a custom, second channel, and you can use this channel instead for Lightmap UVs simply by disabling Generate Lightmap UVs:

Configuring Lightmap UVs
For meshes with two UV channels, you can enable Swap UVs from the object Inspector to switch channel...

Baking lightmaps - Resolution and size

Our scene now features marked static objects, complete with Lightmap UVs, and is ready for lightmapping. The default settings for all Unity scenes and projects is not compatible with a full lightmap setup as we require, and so we must access the lighting settings. To do this, display the Lighting window by navigating to Window | Lighting | Settings from the application menu. Once opened, dock the free-floating window into the object Inspector as a separate tab. This is convenient because we can view the lighting settings and inspect the Scene viewport side by side:

Accessing the Lighting window

First, let's disable all precomputed GI settings by removing the check mark from the Realtime Global Illumination checkbox in the Realtime Lighting rollout. This completely deactivates real-time GI for the scene. In addition, specify the night...

Baking lightmaps - Details

Having now established a resolution and Lightmap Size, we should specify baking details to improve the quality and appearance of our lightmaps. To do this, enable Ambient Occlusion and tweak the Max Distance field until you get the volumetric effect desired. This requires rebaking. Ambient Occlusion is sometimes called Contact Shadows, because it generates shadows where two or more solid bodies meet, such as the floor meeting the wall, or crevices and cracks. This creates a volume effect, enhancing the 3D feel of a scene:

Enabling Ambient Occlusion

In addition, enable Final Gather. Set the Ray Count to 256. Final Gather reduces noise and improves the quality of lightmapping. Higher values result in smooth, higher quality output at the expense of the calculation time:

Enabling Final Gather

Finally, you can increase the resolution of specific objects...

Light Probes

The lightmap setup works well for the scene, but applies only to static objects, such as walls, floors, ceilings, and props. Animated and movable objects, such as NPCs, will continue to be illuminated by expensive dynamic lights, in contrast, unless additional steps are taken; let's take those now using Light Probes. They are special sampling objects, that should be positioned strategically around the scene to record an average of light color and intensity at that location. When multiple Light Probes exist, movable objects such as characters are illuminated by interpolated values taken from the nearest probes. Light Probes, therefore, record color and intensity, but they do not cast shadows. To get started with Light Probes, create a new game object to act as the parent of all probes. Navigate to GameObject | Create Empty from the application menu, and name this...

Lighting FAQ

This section takes time out to explore lighting issues and problems that sometimes arise and common methods to solve them. The issues listed here may not arise for the Dead Keys project specifically, but it's likely that you'll encounter them somewhere, on some projects. Consequently, it's good to know how the issues are solved, or at least avoided. This section takes a question and answer format:

  • Scene lighting appears wrong when opening a scene in the editor: This happens when Auto Generate is enabled from the Lighting window. As the scene is opened, lighting is rebaked. This may take time or may fail entirely for various reasons. The result is that scene lighting may not appear correct instantly when a scene is opened. You can resolve this by disabling auto generate from the Lighting window and then saving the scene to confirm the change. The next...

Navigation mesh

Now, it's time to explore NPC intelligence and, specifically, path finding. We'll need our NPC zombies to move around the scene intelligently, that is, to move without bumping into walls, floors, doors, and other obstacles, and without taking the most complex routes to nearby destinations. Our zombies must cleverly navigate their way around the environment, whatever its arrangement, finding their way toward the player to engage in combat, as though they really had brains! To achieve this, a navigation mesh is required. This is an invisible mesh asset, generated by Unity, to approximate the scene floor for both exterior and interior environments. More accurately, it represents the total walkable floor of the scene--the area over which NPCs may maneuver to travel from point to point. To access the navigation mesh features, click on Window | Navigation from...

Occlusion Culling

Unity imposes no official limits on the size of your scene, and there's no established convention or industry-standard making recommendations about scene size. This is a decision largely in your hands, but there will certainly be a limit in a practical sense. The complexity of meshes, materials, and special effects combined with the number of meshes and their spread determines just how computationally expensive a scene is when presented to a camera with a specific frustum and field of view. Unity tries to make scene rendering easier on the computer by applying Frustum Culling automatically, that is, it silently deactivates (culls) objects outside the viewing volume (frustum) of the camera. As objects leave the frustum, Unity ceases to render them, and as they enter the volume, Unity starts rendering them. This optimization works well in many cases, for objects...

Creating a player camera

The camera object is, in many ways, the most important in any scene, because without the presence of at least one camera, the scene can't be rendered at all. Dead Keys will eventually feature multiple cameras, each with a dedicated purpose. However, let's focus on the main camera, that is, the player perspective in the scene now. For first person games, you can create a camera easily by dragging and dropping a First Person Controller from the Project panel into the scene, from the Characters asset package. However, for Dead Keys, we don't need that; our camera path is fixed as it moves through the level and the user doesn't need free-look controls with the mouse or W A S D keys. Consequently, we'll create a custom camera from the ground upwards.

Let's start by creating a camera object by navigating to GameObject | Camera from...

Particle systems

Particle systems are great for creating effects such as rain, snow, steam, sparkles, hordes of birds, footprints, armies of ants, and more. Unity ships with preconfigured particle systems ready to use, and it lets you create your own from scratch. Here, we'll use some premade systems that can be added easily to the scene, for drama and tension. To access the premade systems, import the ParticleSystem package into the project. Choose Assets | Import Package | ParticleSystems from the application menu if you've not imported the package already. From the Import dialog that appears, accept the default settings and click on the Import button:

Importing Unity particle systems

Once imported, you can access all premade particle systems via the Project panel, through the Standard Assets | ParticleSystems | Prefabs folder:

Access ParticleSystem packages

For...

Music and audio

To complete basic level configuration and structure, let's add music, specifically, the main background music that should play continuously throughout the level. In the last chapter, we imported audio assets, both music and sound effects, and configured these optimally. As discussed earlier, it is most important that music is configured for Streaming as the Load Type, and the Compression Format should be set to Vorbis. This ensures that Unity doesn't load the complete track into memory as it would do with sound and audio. Loading complete music tracks will be performance prohibitive, especially for mobile devices and legacy hardware:

Configuring music audio

In addition to importing music assets, let's create an Audio Mixer asset. This is optional in theory, as Unity can play audio without a mixer. However, mixers give you more control over different...

Summary

Congratulations! You've now created the first level of Dead Keys. Of course, more will be added, but let's first focus on creating one functional level, whose behaviors may be easily recycled to produce more levels, as needed. This chapter focused on many level design issues, both practical and theoretical. Specifically, we explored level design tips and tricks--methods for producing levels more simply and conveniently. In addition, we examined the modular building technique, alongside more advanced tools such as lightmapping, navigation meshes, and Occlusion Culling. In the next chapter, we'll examine how to take the first person camera and build player functionality using animation and scripting.

Left arrow icon Right arrow icon

Key benefits

  • Create professional grade games with realistic animation and graphics, particle systems and game physics with Unity 2017
  • Unleash the power of C# scripting to create intelligent game AI and professional grade game workflows.
  • Create immersive VR games using the latest Unity 2017 VR SDK.

Description

Do you want to make the leap from being an everyday Unity developer to being a pro game developer? Then look no further! This book is your one-stop solution to creating mesmerizing games with lifelike features and amazing gameplay. This book focuses in some detail on a practical project with Unity, building a first-person game with many features. You'll delve into the architecture of a Unity game, creating expansive worlds, interesting render effects, and other features to make your games special. You will create individual game components, use efficient animation techniques, and implement collision and physics effectively. Specifically, we'll explore optimal techniques for importing game assets, such as meshes and textures; tips and tricks for effective level design; how to animate and script NPCs; how to configure and deploy to mobile devices; how to prepare for VR development; how to work with version control; and more. By the end of this book, you'll have developed sufficient competency in Unity development to produce fun games with confidence.

Who is this book for?

If you are a Unity developer who now wants to develop and deploy interesting games by leveraging the new features of Unity 2017, then this is the book for you. Basic knowledge of C# programming is assumed.

What you will learn

  • Explore hands-on tasks and real-world scenarios to make a Unity horror adventure game
  • Create enemy characters that act intelligently and make reasoned decisions
  • Use data files to save and restore game data in a way that is platform-agnostic
  • Get started with VR development
  • Use navigation meshes, occlusion culling, and Profiler tools
  • Work confidently with GameObjects, rotations, and transformations
  • Understand specific gameplay features such as AI enemies, inventory systems, and level design

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 30, 2017
Length: 568 pages
Edition : 2nd
Language : English
ISBN-13 : 9781788398398
Vendor :
Unity Technologies
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Oct 30, 2017
Length: 568 pages
Edition : 2nd
Language : English
ISBN-13 : 9781788398398
Vendor :
Unity Technologies
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 617.97
Mastering Unity 2017 Game Development with C#
zł221.99
Unity 2017 Mobile Game Development
zł197.99
Unity 2017 Game Optimization
zł197.99
Total 617.97 Stars icon
Banner background image

Table of Contents

8 Chapters
Preparation and Asset Configuring Chevron down icon Chevron up icon
Level Design and Structure Chevron down icon Chevron up icon
Player Controls - Movement Chevron down icon Chevron up icon
Player Controls - Typing and Health Chevron down icon Chevron up icon
Enemies and Artificial Intelligence Chevron down icon Chevron up icon
Project Management and Version Control Chevron down icon Chevron up icon
Persistent Data - Load and Save Game States Chevron down icon Chevron up icon
Performance, Optimization, Mobiles, and More Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.5
(2 Ratings)
5 star 0%
4 star 50%
3 star 0%
2 star 0%
1 star 50%
Cliente de Amazon Dec 05, 2018
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Muy completo en conceptos y en cómo administrar tus assets en tu proyecto. Solo debería tener más ejercicios prácticos
Amazon Verified review Amazon
Wirv Feb 11, 2019
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
per un libro chiamato Mastering unity game development, ci si aspetta qualcosa di avanzato e che sia indirizzato a specializzarsi o che tratti di un progetto più generico o verso un tipo di titolo più complesso, invece questo libro è più adatto per un genere di nicchia quale è, inoltre non aiuta a comprendere dinamiche e workflow più attuali.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.