34,79 €
Blender is an incredibly powerful, free computer graphics program that provides a world-class, open-source graphics toolset for creating amazing assets in 3D. With Mind-Melding Unity and Blender for 3D Game Development, you'll discover how adding Blender to Unity can help you unlock unlimited new possibilities and reduce your reliance on third parties for creating your game assets.
This game development book will broaden your knowledge of Unity and help you to get to grips with Blender's core capabilities for enhancing your games. You'll become familiar with creating new assets and modifying existing assets in Blender as the book shows you how to use the Asset Store and Package Manager to download assets in Unity and then export them to Blender for modification. You'll also learn how to modify existing and create new sci-fi-themed assets for a minigame project. As you advance, the book will guide you through creating 3D model props, scenery, and characters and demonstrate UV mapping and texturing. Additionally, you'll get hands-on with rigging, animation, and C# scripting.
By the end of this Unity book, you'll have developed a simple yet exciting mini game with audio and visual effects, and a GUI. More importantly, you'll be ready to apply everything you've learned to your Unity game projects.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 464
Veröffentlichungsjahr: 2021
Unleash the power of Unity and Blender to create amazing games
Spencer Grey
BIRMINGHAM—MUMBAI
Copyright © 2021 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Rohit Rajkumar
Publishing Product Manager: Aaron Tanna
Senior Editor: Hayden Edwards
Content Development Editor: Aamir Ahmed
Technical Editor: Saurabh Kadave
Copy Editor: Safis Editing
Project Coordinator: Ajesh Devavaram
Proofreader: Safis Editing
Indexer: Subalakshmi Govindhan
Production Designer: Aparna Bhagat
First published: December 2021
Production reference: 1261121
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80107-155-0
www.packt.com
For mom and her all-encompassing love. For dad, I hope you're watching. For A and A, my inspiration and motivation. Ad astra per aspera.
– Spencer Grey
Spencer Grey is a native New Yorker who started making games by typing in source code from magazines (that used to be a thing!). Once upon a time, he was creative director of Sesame Street's digital group where he would boss around Elmo and Big Bird. After that, he cofounded Electric Funstuff and for 15 years developed game ideas for companies such as Scholastic, Sony, and Lego. Spencer has been a teacher, programmer, writer, and producer in the games industry. Mr. Grey is definitely not related to the grey aliens stored in Area 51. Definitely not. No way.
Many thanks to the excellent team at Packt who made this an efficient and pleasant process. Thank you, Pratik, Aaron, Hayden, Aamir, Divij, Saurabh, and the others I haven't met. Thanks also to the human race for being such complex and amusing creatures.
Stefan van der Vyver lives in Cape Town, South Africa. He was born in 1975 and started coding in 1987. Coding experience involved Turbo Pascal, Python, Visual Basic, C#, .Net, .ASP, PHP, HTML5, Javascript, AngularJS, and REACTJS. Stefan started working on Blender 3D in 2003. He worked on professional 3D animation, in conjunction with software development for more than a decade before eventually focusing on software development.
Unity 3D was used as the primary development platform for an educational virtual world development in South Africa from 2011 to 2014 where Stefan was developer and product lead. Stefan is passionate about education and the role of technology in education. As a Senior Software Developer he is heavily involved in developing new products and coming up with innovative architecture solutions.
Being involved with book reviews allows him to keep his skills up to date, and to give back to the community.
Sungkuk Park is a Berlin-based game developer. He majored in art studies at Hongik University in Seoul but turned into a software engineer in the gaming industry. His interests cover almost everything about gaming. Now he has started a career as a technical artist.
Publications:
Author of Seamless Society, July 21, 2020, in collaboration with the online exhibition platform DDDDAuthor of Wallpeckers: Breaking down the barriers between media, an article in Korean Art magazine Misulsegye, March 2019Author of The Possibility of the Impossibility of the "Art Games", an article in Korean Art magazine Misulsegye, February 2017Translator and editor of Game Level Generation Using Neural Networks, a featured post of GamasutraSpace. The final frontier.
Don't you just wish you could fill it up with amazing video games that you make yourself? The Unity game engine by itself is a great tool for achieving this, but if you are an indie game developer, hobbyist, or student, you may feel limited because quality assets that make your game shine cost M-O-N-E-Y. Or do they?
The Blender 3D/2D modeling application removes this obstacle. Blender is a free, open source, battle-tested, and sophisticated tool that allows you to create an infinite number of visual assets for your games, limited only by your imagination and how much effort you want to invest.
This book takes you on a whirlwind tour of both Unity and Blender, teaching you to use both of them in a complementary fashion and touching on some of the most powerful features of each.
By the end of the book, we will wind up with a mini-game level for which we will have created most of the assets—animated scenery and an animated character—ourselves from scratch. We will also touch on ways to add polish to your games, such as audio, lighting, and post-processing. More importantly, the knowledge acquired in this book can be applied to just about any project in any game genre. Strap yourself in, it's gonna be a heck of a ride…
I am imagining that you are an eager indie game developer, hobbyist, or student. Or perhaps you are a savvy industry professional who recognizes that this book is bound to become a collector's item and are looking to cash in.
At any rate, this book assumes that you have just a smattering of Unity knowledge, with the following at a minimum:
Understand how all your assets live in your Project ViewUnderstand the Scene View and how to navigate aroundUnderstand how game objects appear in the HierarchyUnderstand how to examine an object in the InspectorUnderstand how to add components and C# scripts to an object and run your gameHonestly, if you don't already have these skills, you can acquire them in about 20 minutes from one of the gazillion YouTube videos or books that cover them. This book assumes you have no prior knowledge of Blender. If you do, please sign up for a mind-wipe first.
Chapter 1, Melding Unity and Blender, achieves lift off in a very gentle fashion. We first take a quick look at Unity, its capabilities, its history, and why you might choose it over competing game engines. Next, we do the same with Blender. Finally, we cover the knowledge, software, and hardware prerequisites for using this book (there are very few!).
Chapter 2, Gathering Our Resources, begins by talking about project setup and provides a light backstory for our minigame. We move on to explore the Asset Store and the Package Manager and conclude by learning to export assets from Unity, getting them ready for Blender.
Chapter 3, Entering the Blender Zone for the First Time, introduces the Blender interface and some of the key tools (out of the many, many, many available) we will be using. Next, we spend time learning to alter a pre-existing asset and getting ready to return it to Unity.
Chapter 4, Asset Assimilation: Returning to Unity, delivers on the promise of the previous chapter. We take our modified asset, texture it, animate it, and script it. We make it an apocalyptic (almost) weapon that can shoot with audio and visual effects.
Chapter 5, On the Level: Making Modular Scenery, starts by defining what all this "modular" business is about. Then we get into some good stuff, creating sci-fi scenery from scratch and learning to UV-unwrap it (we also define UV-unwrapping!).
Chapter 6, Living It Up: Adding Fun with Animation, delves further into Blender. We learn some basic animation techniques, creating more scenery, animating it, and texturing it.
Chapter 7, Prep Work: Materials, Grids, and Snapping, returns to Unity for further work on our new assets. We improve their materials and also learn about Grid and Snap settings for level layout.
Chapter 8, Laying Out the Level, continues building on the last chapter. We actually lay out our minigame level and then we add a little pizzazz with a Skybox and ambient sound and music.
Chapter 9, Secret Weapon #1: Deploying ProBuilder, examines an under-utilized and relatively recent addition to Unity: ProBuilder. We learn when you might want to use ProBuilder instead of Blender and we get our feet wet by starting to craft one of the final areas of the game.
Chapter 10, Secret Weapon #2: Animating with Timeline, shows us another animation tool in Unity that confusingly has the same name as a Blender tool. We learn when you might want to use one rather than the other and we animate what we created in the previous chapter.
Chapter 11, We Could Be Heroes: Blender Character Modeling, covers our most complex Blender modeling challenge yet: a space marine! We will get lots of practice with previous Blender tools and learn new ones along the way.
Chapter 12, It Was Rigged!: Character Rigging, covers what character rigging is, why it is important, and then—by golly—we go ahead and miraculously rig our character.
Chapter 13, Animation and Movement In-Game, covers all sorts of great stuff: we get our marine moving with sound effects, we follow the marine's movement with a Cinemachine virtual camera, we add lights to the level, and we animate our blast doors and the bridge. This chapter has everything but the kitchen sink!
Chapter 14, Endgame: Adding Spit and Polish, brings everything to a close, and yet it is just the beginning. How paradoxical. We teach the marine to both shoot and die. We teach the turret how to explode in spectacular fashion. The missile too! We create a main menu and learn to build our game. Then we add some post-processing visual effects and a final area to conclude the game. Mission accomplished!
As I mentioned earlier, there are very few requirements for this book. You do not need any Blender knowledge, and you need about 20-minutes-worth of Unity knowledge that you can glean from any number of readily available free sources, or—heck!—you could even crack open the Unity manual and teach yourself!
If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book's GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Mind-Melding-Unity-and-Blender-for-3D-Game-Development. If there's an update to the code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
The Code in Action videos for this book can be viewed at https://bit.ly/30yLR5Q.
We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781801071550_ColorImages.pdf.
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system."
A block of code is set as follows:
void Update() {
// todo cast a ray forward
// if it hits something, do the following...
return; // not very exciting, I know
}
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
void InitSpaceport() {
InitPerimeterDefenses();
OrderHyperlunchForStaff();
RunGarbageDisposalDiagnostics(); // it's been acting up
RelocateTeleporterPad();
}
Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: "Select Vaporize Intruders from the Defensive Countermeasures panel."
Tips or Important Notes
Appear like this. One good tip is to read all the tips. You might learn something new.
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Once you've read Mind-Melding Unity and Bender for 3D Game Development, we'd love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we're delivering excellent quality content.
In a very speedy excursion, we export an asset from Unity, import it into Blender, perform a simple modification, and then import it back into Unity.
This section comprises the following chapters:
Chapter 1, Melding Unity and Blender Chapter 2, Gathering Our ResourcesChapter 3, Entering the Blender Zone for the First TimeChapter 4, Asset Assimilation: Returning to Unity"The journey of 1,000 parsecs begins with a single thruster burn." – The AutoSage of Rigel VI
Hello, Earthling! How would you like unlimited cosmic power? That is essentially what you get when you use the ultra-versatile Unity game engine in combination with the awesome assets you can create with the Blender graphics toolkit. "Wait a minute," you say with worry, "that much power sounds expensive." Well, worry not! All that power can be had for the low, low price of… nothing!
(Full disclosure: if you start making more than $100,000 a year with Unity, you need to start paying a licensing fee. You should be so unlucky!)
This book starts you on the path to that unlimited power. Once begun, it is a never-ending journey bounded only by your effort and imagination. Unity and Blender go together like some of the most famous human combinations:
Peanut butter and jellyPen and paperThelma and LouiseOn our journey, we will learn how to create, alter, texture, animate, and script 3D objects in Unity and Blender and exchange them between the two programs in our pursuit of making breath-taking, mind-altering, fun-inducing, superlative-worthy video games.
This chapter lays the groundwork for what lies ahead. We will cover the following:
What is Unity and why choose it?What is Blender and why choose it?What software, hardware, and knowledge should you have to make this journey?Unity is a paradox. It is a video game engine that is not a video game engine, or rather, it is so much more than that.
Firstly, what's a video game engine? Aww, come on. Are you really reading this book and asking that? Okay, you are forgiven. Maybe you are recovering from a mind-wipe. A video game engine is a software tool that helps you to create a video game. One example of an incredibly famous video game engine would be… Unity!
Unity was first released in 2005. It was available only on Mac and could only publish games for Mac. That very quickly changed and now, over a decade later, Unity is a mature and capable (though not yet sentient) piece of software. Unity is available for use on Windows, macOS, and Linux. As of this writing, Unity can create 3D and 2D games for more than 25 different platforms! These platforms include Windows, macOS, and Linux as well as WebGL, PlayStation, Xbox, Nintendo Switch, various virtual reality and augmented reality platforms, and more!
Here is an example of a made-in-Unity, first-person-shooter:
Fig. 1.1 – Escape from Tarkov. Developer: Battlestate Games
And here is an example of a retro 2D arcade game:
Fig. 1.2 – Cup Head. Developer: Studio MDHR
When I say Unity can "create games," I don't actually mean it can only "create games." That's just the tip of the planetoid. Unity is currently used to create many different kinds of experiences in areas and industries besides video games, including the fields of virtual/augmented/extended reality (VR/AR/XR), simulation, real-time cinema, film pre-visualization, and automotive design and marketing. Oh yeah, let's not leave out construction, architecture, art installations, engineering, and research data visualization. Got all that? For those of you sitting in the back, there may be a pop quiz later.
Now, it's true that there are other powerful game engines out there, such as Unreal, Godot, and so on. So why should Unity be your go-to game engine of choice?
These are the top reasons for using Unity as your game engine of choice:
Versatility: If you can dream it, you can build it, all the way up to AAA titles. Unity has an amazing toolset that allows you to create 2D and 3D games ranging from the very simple to the very complex. It can be your go-to choice whether you are re-making Pong or creating the next best MMORPG.Ease of Learning: To be clear, Unity development can get very complex. But to get started with Unity and produce something surprisingly fun and advanced can take as little as 15 minutes. And Unity caters to different learning styles, with visual scripting available for those who prefer that to code editing.Portability: With little to no modification, you can get your latest masterpiece running on a number of the many platforms Unity supports, including desktop, web, mobile, and XR!Community: You are not alone. Unity has a development community of over 1.5 million people. You read that right, 1.5 million humans. Of course, that is insignificant on a galactic scale, but from your limited perspective, it is quite impressive. This means that if you run into a problem or need advice, the answers are out there in cyberspace. The Unity developer community is very friendly and encouraging as well. Learning support: Unity has excellent documentation as well as an extensive, dedicated, free learning site: https://learn.unity.com. This is not to mention the hundreds of high-quality tutorial videos on YouTube as well as the many excellent how-to books available (such as this one!).Customizability: Every developer and every project is different. The Unity editor is tremendously configurable and even programmable. You can create in-editor custom tools to make working on your specific game much easier. And if you need a certain special visual quality for your game? Even the rendering pipeline Unity uses for graphics is programmable and customizable. Price: Free! Did I mention that already? You only need to start paying a fee if your games start making gobs of money. Gobs.Reach: You have certainly played a Unity-made game before whether you knew it or not. As of the writing of this book, Unity games have reached over 500 million gamers and the Unity engine is responsible for creating 34% of free mobile games on the market. Unity games reach every game market there is.Assets: 3D models, 2D art, visual effects, sound effects, GUIs, tools, templates, and much more. Back in the bad old days of game development, there were some powerful game engines and development technologies available (anyone remember Microsoft's XNA?) but, as an indie developer or hobbyist, there was nothing to put into your game unless you created it yourself or paid (or mind-controlled) a talented artist. It cannot be overstated how valuable the Unity Asset Store is, whether for assets to use in prototyping or in your final release. And some very high-quality assets are available for free. In fact, on our journey, we will use multiple free assets in addition to the ones we create.Development Support Tools: Unity includes tools for integration with different code editors/IDEs, version control systems, asset creation tools (such as Photoshop), and it supports collaborative team development as well.Monetization-Friendliness: Unity wants you to profit from your efforts! Built-in packages such as Unity Ads and In-App Purchases make it easy to build revenue opportunities into your game. And the Unity Analytics tools allow you to discover and make use of insights about how players play your game. Even minor game changes can greatly boost the success of your game.Maturity: Unity has been around long enough that most of its sharp edges have been smoothed. Over and over, every day the engine proves itself to be stable, effective, and reliable.With Unity explained away, let's take a look at the other focus of this book…
Well, firstly, Blender is not a kitchen appliance. If you try to make a game with Unity and that kind of blender, the results could be interesting, but it sounds rather dangerous and messy.
Blender is described as a "computer graphics software toolset." It was first and foremost designed to create sophisticated 3D graphics when it was released in 2002 but now is capable of producing spectacular 2D creations as well.
Blender is free and (unlike Unity) open source. It is used every day for creating assets and animations for computer games and visualizations. In addition, it can create animated films, visual effects, and artwork, models for 3D printing, simulations of fluid, smoke, and soft bodies, and it also does video editing and compositing. Did I mention it's free? As in, costing no money.
So, what's the catch?
It's a beast.
When you first experience Blender, especially if you have had no previous experience with 3D creation software, you may get dizzy and get a nosebleed and want to pilot your ship into the heart of a quasar. But fear not! That will pass!
As intimidating as Blender may seem at first, it can be mastered. The secret is to tackle it a little bit at a time, learning bits of related functionality, and to understand and believe that there is a method to Blender's glorious madness. As an open source project it has grown in different directions with its community and it has its own particular way of doing things. At some point, you will just "get it."
If you are brave and determined and attentive, you will achieve great success. You get out of it what you put into it (in that sense, it is like the kitchen appliance!).
Here is some Blender "wow":
Fig. 1.3 – A Party Tug at 6:00 A.M., by Ian Hubert
As with Unity, there are many powerful, competing Digital Content Creation (DCC) programs available, two of the biggest being 3DS Max and Maya. So why would we use Blender over one of those?
Although this list isn't as long as the one for Unity, many of the reasons to use Blender are the same and they are no less important.
The top reasons to use Blender are:
Free and open source: Other industry-standard 3D applications (such as 3DS Max, Houdini, and Maya) cost thousands of dollars. Blender gives you AAA graphics capabilities for nothing. The fact that Blender is open source might not seem like an immediate benefit to non-programmers, but it actually has tremendous benefits. See Extensibility, below.Versatility: This book will focus on using Blender for modeling, texturing, and animation, but Blender is a treasure trove of functionality. Unlike other proprietary modeling programs, Blender is more of a "one-stop shop", with capabilities that include powerful 2D graphics creation and animation, motion tracking, and video compositing, among others.Community: Blender has a huge user base, with some estimates putting it at around three million Earthlings. Like the Unity community, it is very friendly and helpful, providing support and inspiration.Learning Support: In addition to the official Blender documentation, there are hundreds of excellent YouTube videos to help you learn, not to mention highly valuable resources available in book form (ahem!).Fast Workflow: Once you get comfortable with Blender's preferred mouse-and-keyboard work process, you will see your productivity soar. It is arguably faster than the more menu-oriented workflows of other programs. Customizability: Blender is nothing if not highly customizable. You can change just about everything in the UI and input system to your heart's content. Beyond that, the application is programmable via the popular Python language.Lightweight and Multi-Platform: Blender easily runs on Mac, Windows, and Linux. In addition, compared to other top 3D applications, Blender is tiny. It can easily fit on a thumb drive you take with you and run anywhere.Extensibility: Blender has a huge number of existing plugins, ranging from the very general to the super-specific (for example, there's one just for creating rocks). Because Blender is open source, it's not limited by the size of an in-house development team. This means that developers from all over the world are constantly working on new features and creating plugins. Built-in Monkey: Unlike other programs that augment their standard palette of 3D primitives (cube, sphere, and so on) with a teapot, Blender comes with its own 3D mascot, Suzanne the monkey.Show me the monkey!
Fig. 1.4 – Suzanne. Another future overlord?
We have now identified our two primary tools for achieving cosmic power. But what do you need to use them?
We are boldly going where a lucky few have gone before.
In this book, we will get comfortable using Unity and Blender hand in hand, specifically learning how to create new assets in Blender—and modify existing ones—and then incorporate them into a simple sci-fi Unity mini-game project. We will learn how to create materials and do animation in both Unity and Blender, and we will learn best practices for when to use each tool.
By the end of this book, we will have covered an incredible amount of ground (or space?). You will have created, animated, and scripted some science-fiction themed props, scenery, and characters that you can reuse in your future games.
The following sections outline the bare minimum in terms of knowledge, hardware, and software that you will need in order to have a pleasant and productive experience with this book.
Modeling versus Sculpting
Blender has two primary 3D creation methods: polygonal modeling and sculpting. Polygonal modeling focuses on creation by assembling polygons such as quads and triangles, whereas sculpting treats your creation more as if you were shaping something out of clay. The two creation methods have different workflows and tools. This book will focus on polygonal modeling in Blender.
I'll say this: the braver you are, the less you need to know heading into this book. If you follow along closely, you will be able to accomplish everything we set out to do.
That said, there are just a few basic things that will keep your head from exploding and your blood from boiling:
You should have a rough familiarity with 3D concepts such as x, y, and z coordinates and transformations within that space: translating, rotating, and scaling. It helps if you have heard of vectors, but no knowledge of 3D math is assumed.You should have a basic knowledge of using the Unity editor's Scene View and Hierarchy View to place and manipulate a GameObject.You should understand how to examine and manipulate the properties of a GameObject in the Inspector window. You should also understand how to add a Component to your GameObject in this window. You are able to create a new C# script, add it to a GameObject, and edit it in the code editor of your choice. In this book, we will use Visual Studio. A basic understanding of C# will be helpful to complete the projects, but the code that is included is clearly explained. The majority of this book is not very code-heavy; it is only toward the end of this book, when we start to bring together all the assets we have created, that we will make the most use of scripting.You should know the basics of using an image-editing program such as Photoshop. This knowledge will only be necessary for sections on texturing assets.If it has not been made clear, you do not need to have any prior experience with Blender.
At a bare minimum, you will need copies of both Unity and Blender installed, updated to the current version of each. As of this writing, the latest version of Unity is version 2020.3.21 and the latest version of Blender is version 3.0.0..
Both programs are cross-platform and available for macOS, Windows, and Linux.
The latest version of Unity can be found at https://unity3d.com/get-unity/download.
It is strongly recommended that you install the Unity Hub software, which helps you manage your projects, your editor installations, and also provides access to key learning materials.
The latest version of Blender can be found at https://www.blender.org/download/.
In addition to Unity and Blender, you should have access to an image-editing program. Photoshop is the industry standard but comes with a price tag. A free alternative is GIMP, which can be downloaded here: https://www.gimp.org/downloads/.
Blender itself has some image-editing capability. Although we will not delve into it, you may want to explore that if you don't use other alternatives.
Software needs a place to run, doesn't it? So how do we decide between a desktop computer versus a laptop versus a tablet?
Well, the tablet question is easy to answer. Blender will not run on a tablet. So a desktop or laptop it is then. The particular hardware requirements for Unity and Blender can be found at these locations:
Unity: https://unity3d.com/get-unity/downloadBlender: https://www.blender.org/download/requirements/In general, you should do fine with a system that is younger than 5 years old and has DX10 (shader model 4.0) capabilities with a full HD display.
Using a 3-Button Mouse
Yes, you can technically use Blender and Unity without a 3-button mouse. But that is like saying that technically you can survive in outer space without a spacesuit. Those 10-15 seconds you would survive would be pretty painful. In other words, use a 3-button mouse. Your sanity will thank you.
Now, I understand that many of you are going to be naughty and flit about between chapters like an over-caffeinated hummingbird.
Personally, I believe you will get the best learning experience from this book by reading it in chapter order and—although I make efforts to have chapters be as self-contained as possible—I specifically try to have later tasks and concepts build on earlier ones. That said, it is still quite possible to jump around the chapters willy-nilly, like the aforementioned hummingbird. Your eventual punishment for doing so will not be too severe.
One book, even one as awesome and mighty as this one, cannot cover everything, especially when it deals with two complex programs.
Thus, I encourage you to use this book as a launchpad and when you invariably encounter new situations where you need additional help, to make full use of the ample free resources available at your (virtual) fingertips.
The official Unity Support page is at https://unity.com/support-services and the extensive community forums are at https://forum.unity.com.
The official Blender support page is at https://www.blender.org/support/.
There are many other unofficial high-quality support sites if you do a little Google searching.
As mentioned, YouTube.com has a vast array of tutorial and showreel videos.
Packt Publishing also has an extensive line of books for Unity and Blender that delve into many specific topics in much more detail than we can go into here. A complete list can be found by searching at https://www.packtpub.com/.
Let's review. In this chapter:
We've identified key capabilities of both Unity and Blender and looked at why you should choose these programs over their competitors.
Also, I've flagged that you do not need any prior experience with Blender, but it will help greatly if you have a modest familiarity with Unity.
Besides that essential up-front knowledge, we've looked at what software you will need installed and what hardware will get the job done with the least amount of pain.
We've foreshadowed the mini-game level we will develop in this book, which will give you the skills and confidence necessary to go on and create bigger and bolder things in your other projects.
Coming up next, we will gather the necessary resources for our journey, becoming familiar with the Unity Asset Store and setting up the project where all the action will take place.
Ready to become a master of time and space? I hear your engines firing up and I have received your request to launch. Permission granted.
3… 2… 1… lift off!
"Proper preparation prevents poor performance." – An Anonymous Alliteration Advocate
Hello again! I am glad to see we didn't lose you as we exited the stratosphere. You look a little blue though. In your species, that means you're either nauseous or molting.
Before we enter deep space, we are going to stock up on some things we will need for our journey. Although we will make several of our own 3D creations, in order to make our final mini-game level extra-awesome, we require not only some additional 3D models, but some sound effects and music, some 2D artwork for textures and our user interface (UI), along with some visual effects.
Where will we acquire these things? From the trusty Unity Asset Store, of course, where many amazing assets can be found for absolutely free. If you want additional supplies such as bean dip and extra towels, you must supply those yourself.
As we pause to stock up, we will cover some interesting topics in this chapter:
How to create and set up the Unity project for this bookDefining our mini-game story and featuresHow to use the Asset Store to find and download assetsHow to use the Package Manager to install and import assetsHow to install the FBX Exporter packageHow to export a Game Object for use in BlenderReady for all that? Let's go!
To follow along with this chapter you will need a copy of Unity installed, which you can get from this link: https://unity3d.com/get-unity/download.
The supporting files for this chapter can be found here: https://github.com/PacktPublishing/Mind-Melding-Unity-and-Blender-for-3D-Game-Development/tree/main/Chapter02
I'm assuming this is not the first time you have created a Unity project, so this will be a super-quick refresher. (If it is your first time, kudos for your bravery. Go slow and see Chapter 1, Melding Unity and Blender, for all the places you can turn to if you get stuck or confused.)
To begin, launch the Unity Hub.
You did install the Hub, didn't you? It just makes life so much easier. If you don't have it installed, stop resisting my mind control and go get the Hub from here: https://unity3d.com/get-unity/download.
With the Hub installed and launched you should see something that looks like this:
Fig. 2.1 – The Unity Hub
In previous projects you may have zoomed past the Hub window, but I just wanted to draw attention to all of the functionality that is packed into this launcher app. If you look at the area labeled 1. in the preceding screenshot, you can see the following four choices you can choose from:
Projects: By far, this is what you will most often choose when you launch the Hub. If you look in area 2., you'll see that you can Add an existing project or choose to create a New one.Learn: These are quick links to Unity-provided projects and tutorials. They are excellent quality and can provide you with polished assets to use, as well as showing you professional ways to structure your projects and code.Community: Again, these are quick links to the Unity Blog, Forums, and so on.Installs: Here, you can see all the different versions of the Unity editor you have installed, and you can find and install new versions, as well as remove old versions.Let's go ahead and create a new project. Click New in area 2.
You should now see the options for creating a new project. Go ahead and choose the 3D project option.
Fig. 2.2 – Project Template options
Next, give your project a name, such as SpaceEscape. Use any name you like, but really SpaceEscape is great, highly descriptive, and a sign of having an advanced intellect. If you want to choose an inferior name, go right ahead.
You may be wondering what some of the other project templates are. More information can be found in the following tip, as well here: https://docs.unity3d.com/Manual/ProjectTemplates.html.
URP and HDRP Pipelines
The Universal Rendering Pipeline (URP, formerly known as the Lightweight Render Pipeline, or LWRP) and the High Definition Rendering Pipeline (HDRP) ship with Unity. They are each an example of a Scriptable Render Pipeline, which is a means of having very fine control over the frame-rendering process via C#. URP provides great scalable performance across Unity platforms, while HDRP provides very high-end graphics and needs appropriate hardware to back it up. Unity's default pipeline is currently known as the Built-In Render Pipeline and is good, but more limited than the scriptable ones. Eventually URP will become the default. In this book we will use the built-in pipeline as we want to skip the additional complexity of working with URP. You can learn more about working with URP at https://learn.unity.com/tutorial/introduction-to-urp. Information about HDRP can be found at https://learn.unity.com/tutorial/introduction-to-hdrp-2019.
Once you have selected the 3D template, click on Create and wait for the Unity editor to launch.
We have arrived at docking station Unity! A major milestone! Presumably, you've been here before. In fact, you may have altered the application so much as to make it unrecognizable. My opening editor screen looks like this:
Fig. 2.3 – My initial screen layout
If yours looks different, let's be sure we are all starting out from the same place. In the upper right of the screen click Layout and choose Default.
The default layout is not necessarily the best one—it really depends on the task you are trying to do—but it is a good general-purpose layout and gives us a common reference point. Depending on your personal preference and your comfort level with working in the editor, you can experiment with the other layouts or even create your own specialized layout.
Let's do something very simple, but very necessary: creating folders to organize our mini-game. We won't be using most of these until later in the book, but forewarned is four-armed, er, forearmed, I mean.
Right-click within your Project window and create the following folders:
AnimationAudio (also create three subfolders: SFX, Soundtrack, and UI)MaterialsModels (also create a Textures subfolder)PrefabsScripts (also create an Editor subfolder)SpritesUIGo ahead and do that now. I will wait.
*Spencer waits awhile*
Okay, be honest. You didn't do it, did you? If not, the following tip is for you…
Tip: Don't be lazy!
Develop good organizational habits early! You may say, "I'll come back and clean things up later." Wrong! "Later" never happens and as your project grows, it will become a mess and your head will explode! "Just do it," as the sneaker people say. Your future self will thank you.
There are many different ways to structure your project. You will encounter other ways as you are exposed to other people's projects. The way we do it here is, of course, superior, but you will only realize that by seeing inferior ways of organization.
The more important thing is to be consistent. That way, when you revisit a project in the future or if, hopefully, you share the project with someone else, the structure is predictable, and you won't have to rely on the search bar for everything.
One additional tip is to decide whether to view your project assets as icons or textual labels. If you look at the Project detail pane, by default, Unity displays your files as medium-size icons:
Fig. 2.4 – The Project assets view
In the lower right is a slider. If you drag the slider to the right, the icons will become bigger, but time and space as we know it will end because no one needs icons that big.
If you drag the slider to the left, the icons will shrink until they eventually become much more reasonable text labels:
Fig. 2.5 – A superior view of your project, showing text labels!
I prefer the compact label view. But it's your planet (for the time being), so you decide. Now, let's pause and think about the Big Picture.
If we don't know where we are ultimately heading, we are liable to navigate right into a black hole or worse. Let's add some definition to what we want our mini-game level to be like by the end of the book.
First, we'll come up with a backstory. Although not strictly necessary, this will add flavor to the vision in our minds. It will influence the choices we make about the assets we acquire and the ones we create, as well as influence the choices we make about the game mechanics and layout. Plus, of course, the fact that this backstory has the ring of truth to it…
(Darken theater. Cue music.)
Not very long ago, in a nearby galaxy…
An ancient splinter colony of technologically advanced humans came across the sinister plans of a shape-shifting alien race to infiltrate a small blue planet orbiting a yellow sun. The benevolent humans took it upon themselves to warn their brethren and they captured the aliens' invasion plans.
After a fierce battle, a lone space marine found himself (herself?) with the last remaining chance to get the plans off the planet. To do so, the brave marine would have to overcome the automated defenses of the aliens' starport facility. The odds were slim, but space marines eat slim odds for breakfast. Along with donuts.
Sound good? I'll leave it to you to decide who will star in the movie.
We are going for simple here, since the thrust of the book is about assets, not coding, but we still have a huge number of options open to us, especially considering how easy Unity makes developing different genres of games. One of the most popular is the first-person shooter (FPS) style, but we are not going to choose that. Why? Because we will be creating our own hero character model and we want to get a good look at them.
Similar to some old-school RPGs, our mini-game will be a 3D over-the-shoulder game where you move your character with the arrow keys. Interactions such as opening doors and activating the telescoping bridge asset will be automatic.
Again, just to drive the point home, we are going for simple. Clearly, we are targeting a desktop/laptop with this control scheme, but everything we are learning about assets and animation in this book is completely generic and could equally be applied to touch games on mobile devices or controller-driven console games. Packt offers several books on mobile development. To find them, you can go to https://www.packtpub.com/ and search for Unity mobile.
Ready to start bringing everything to life? Let's gear up.
Okay, so far in our project we have some empty folders. Very exciting. Let's start filling them up at one of any Unity developer's favorite websites: the Unity Asset Store!
The Asset Store is an indie dev's dream: it is a digital marketplace offering quality content of every type imaginable, but it is also a bargain bin filled with hidden treasures available at little to no cost. How do you get to this place of wonders? Well, one way is from the Unity editor. In the top menu bar, choose Window > Asset Store.
Doing this will pop open a new window. But what's this? Where is the Asset Store?
Fig. 2.6 – The Asset Store moved! Where'd it go?
Fear not! The Asset Store used to be accessible from within the Unity editor but is now only usable via a browser. This is because of Unity's effort to improve editor performance. It's no big deal.
Notice there is a checkbox that will have your browser open automatically if you choose the menu option. Tick the box and click the Search online button. Your browser should launch. If for some reason it does not, or if you simply want to navigate directly to the store in the future, surf over to https://assetstore.unity.com/.
The landing page for the Asset Store changes almost every day, but you should see something similar to this:
Fig. 2.7 – Asset Store homepage
The important things of note are the search bar in the upper left of the window, used for searching of course, and the down-arrow-in-a-box in the upper right, used for accessing the assets you own in your My Assets collection.
When you perform a search, you will get a page that has three main areas:
Fig. 2.8 – Results after performing a search
Area 1 (not to be confused with Area 51 in Nevada!) is an Asset Store promotion. Area 2 shows the search results based on the search term you typed in the bar, and the settings you have set for the search filters are in Area 3.
The filters provide many useful ways to refine your search, ranging from the very basic asset categories, to the price range, editor version, publisher, ratings, platform availability, and release date.
If you are looking for any of the many free assets Unity releases for its tutorials, search for Unity Technologies under the Publisher filter.
A Cornucopia of Content
It's easy to assume that the Asset Store is mostly focused on providing 3D models and 2D artwork for games, but that is just the beginning and does not nearly cover the breadth of what is available. In addition to all manner of 3D characters, props, and scenery, there are texture, animation, and motion capture packs to jazz them up. There are a huge number of jaw-dropping visual effects, vast libraries of sound effects and music, and an astonishing variety of editor tools to enhance your development process in every conceivable way. Lastly, there are many template kits for different game genres (FPS, 2D turn-based strategy, platformer, RTS, and so on) to give you a headstart in your game.
Spend some time searching for your favorite topics and randomly follow links that catch your eye. Explore the home pages of artists whose work you admire. See what else they have. It's a wide, wild asset world. See what's possible. You'll be amazed!
The first asset we will acquire is the one we use to take a quick round-trip from Unity into Blender and back again, modifying the asset to our liking along the way.
In the Asset Store search bar, type in Robo's turret (free sample). The asset we want is a sci-fi blaster turret and it should be first in your search results. You can click that, or if you really enjoy typing, go ahead and point your browser to https://assetstore.unity.com/packages/3d/environments/sci-fi/robo-s-turret-free-sample-147413.
You should see the turret asset home page:
Fig. 2.9 – Sci-fi turret homepage
Initially, the circled blue button will say Add to My Assets. Click that and in a moment the button will change to read Open in Unity. Go ahead and click that, which will lead us directly into our next topic, using the Package Manager.
Having clicked to open the asset in Unity, you will see a floating window that looks similar to this:
Fig. 2.10 – The Package Manager window
Don't worry if it looks a bit different or if it's docked instead of floating. If it says
