41,99 €
Take your game development skills to the next level with one of the best engines on the market
This book is for game developers who have a basic knowledge of Unreal Engine and C++ scripting knowledge. If you want to take the leap from a casual game developer to a full-fledged professional game developer with Unreal Engine 4, this is the book for you.
Unreal Engine 4 has garnered a lot of attention in the gaming world because of its new and improved graphics and rendering engine, the physics simulator, particle generator, and more. This book is the ideal guide to help you leverage all these features to create state-of-the-art games that capture the eye of your audience.
Inside we'll explain advanced shaders and effects techniques and how you can implement them in your games. You'll create custom lighting effects, use the physics simulator to add that extra edge to your games, and create customized game environments that look visually stunning using the rendering technique. You'll find out how to use the new rendering engine efficiently, add amazing post-processing effects, and use data tables to create data-driven gameplay that is engaging and exciting.
By the end of this book, you will be able to create professional games with stunning graphics using Unreal Engine 4!
An advanced guide that will take you to the next level of developing games with Unreal engine with illustrative examples that will make you confident of creating customized professional level games on your won.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 403
Veröffentlichungsjahr: 2016
Copyright © 2016 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, and its dealers and distributors will be held liable for any damages caused or alleged to be 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.
First published: June 2016
Production reference: 1240616
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78588-356-9
www.packtpub.com
Author
Muhammad A.Moniem
Reviewer
Moritz Wundke
Commissioning Editor
Amarabha Banerjee
Acquisition Editor
Larissa Pinto
Content Development Editor
Divij Kotian
Technical Editor
Mrunal M. Chavan
Anushree Arun Tendulkar
Copy Editor
Safis Editing
Project Coordinator
Ritika Manoj
Proofreader
Safis Editing
Indexer
Hemangini Bari
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
Muhammad A.Moniem started in the industry at a very early age. He taught himself everything related to the game development process even before he joined college. After becoming a software engineer, he started to teach himself the art of game design and game art techniques. As a self-taught person, he was able to find his way into the industry very easily, which led him to be hired for big, medium, and small companies, titles, and teams.
Throughout his career, he has been able to contribute as a full-time or part-time employee or freelancer on games for a wide range of platforms, including Windows, Mac, iOS, Android, PS4, Xbox One, and OUYA. He has also worked with technologies such as VR, AR, and Kinect. Muhammad started using Unreal Engine 3 in 2007, moved to Unreal Engine 4 when it became available to the public in 2014, and has used UDK for some indie games.
Eventually, he was able to establish his own one-person game company/team as a part-time independent developer. A lot of his indie games have received recognition or have been finalists at international indie game events, such as IGF, Indie Showcase, IGC, and Tokyo Game Show. You can get in touch via twitter @_mamoniem
He has also worked on Learning Unreal® Engine iOS Game Development, Packt Publishing, which is available at https://www.packtpub.com/game-development/learning-unreal-engine-ios-game-development, and Unreal Engine Lighting and Rendering Essentials, which is available at https://www.packtpub.com/game-development/unreal-engine-lighting-and-rendering-essentials.
I would like to thank all those people who helped me get this book to your hands. A special mention for all the team members at Epic Games for their hard work on Unreal Engine and for the great decision of making the engine for everyone with the source code for free.
I would like to thank all the people at Packt Publishing who worked on this book. They helped me a lot and were patient when I missed the schedule because of my personal obligations. Thanks for helping me and teaching me once again about how to write a book.
I want to express my pleasure of having a lovely wife and wonderful kids in my life. You are my gift. You are a very supportive family, thanks Loly for giving me the best environment to write one more book, and thanks for believing in all my personal projects since you came to my life. You always working too hard for this family! Thanks Joe, Mary, and Oni for being noisy, sweet, and lovely kids all the way. You are a delight to my eyes!!
Yunus, thanks for being the new hope, this book for you…Only for you buddy!
Father and mother, thanks for raising me the way you did and teaching me how to self-learn, it helped me a lot to learn and pass the knowledge to others.
Last but not least, all my friends and the good people I met around the world, you definitely helped me somehow, at least with your trust and belief. Even if you were an online friend, I'm sure I still owe you something…Thank you everyone.
Dear God, thanks for being Muhammad, I like being this person. And thanks for everything I've achieved, please keep those wonderful people around me
Alhamdulillah...It's the last line to write…!
Moritz Wundke, also known as Moss, started programming at the age of 12 and he always knew that he would write games for a living. After finishing his Bachelor in computer science at the University at the Balearic Islands in 2007 he started working with the Unreal Engine 3 at Tragnarion Studios. He left the studio in 2014 and joined the Spanish social game developer PlaySpace working on over then titles and shipping their games to more than 23 million players. In his career he has been able to work with nearly all major platforms, such as the NDS, Xbox 360, PS3, PS4, Android, iOS, Windows and Mac. Apart from his day job, Moritz is an official community moderator of the Unreal Engine community, Engine Contributor and freelance Unreal Engine consultant. He has worked for companies such as Deep Silver on Dead Island 2 and Red Goddess: Inner World for Yanim Studios.
I would like to thank my wife Cecilia for being so patient while I worked late nights and not throwing away my rig and even myself with it.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
This book is an in-depth guide through the process of creating a high quality game from scratch, starting from importing and implementing assets and ending up with packaging the game for release and making patches, with all the steps in-between. The main aim of this book is to make a game that looks awesome, and cover advanced stuff using C++ extensively to build the logic for the game.
Chapter 1, Preparing for a Big Project, shows how to create a new project, set it up, edit its settings and making it ready to rock. Also, the advanced assets pipeline will be discussed so that readers can bring in their models into Unreal Engine.
Chapter 2, Setting Up Your Warrior, explains how to make the game's hero! We will be building a character controller mapped to the keyboard and mouse using C++. You will learn how to create the logic for the character, switch weapons, attack, and move with C++. The class will be converted to blueprints. You will learn how to add in animations and physics to make it move using C++.
Chapter 3, Designing Your Playground, shows how to build the game world! We will be using the editor tools and brushes to build a level, apply lighting and materials to it, and make it ready for the first round of testing the game's logic.
Chapter 4, The Road to Thinkable AI, shows how to build the game's creatures AI, which are going to detect the player and attack them based on distance, sight, and/or the noise made by the player. All scripting will be done in C++. Animations will be taken care of by the editor and some other cool options.
Chapter 5, Adding Collectables, spices things up with some collectables! We will learn about some of the triggering and overlapping events, more about adding new classes, and adding some physics to the collectable items.
Chapter 6, The Magic of Particles, shows how to add in some particles to complete the coolness! We use cascade to build particles for the enemies, weapons, and collectables, and learn to tie these to the game logic.
Chapter 7, Enhancing the Visual Quality, shows how to make the game better looking by focusing on the most important rendering features of the engine, to make things pretty. You will learn to bake light maps.
Chapter 8, Cinematics and In-Game Cutscenes, covers the tools required to build an in-game cut-scene for a better gameplay experience and story direction.
Chapter 9, Implementing the Game UI, shows how to add a solid UI to the game is what will get the players going "Hell Yeah!" Make use of Unreal Motion Graphics (UMG) to tinker with different screen sizes and build a superb looking UI for your game.
Chapter 10, Save the Game Progress, shows how to write a "save and load" function in order to save the progress in order to be able to resume the game later.
Chapter 11, Controlling Gameplay via Data Tables, shows how to use data tables to drive the gameplay values for the enemies and so on (it is widely used in tons of game genres, such as Tower Defense, RPG, Roguelike, RTS and so on)
Chapter 12, Ear Candy, shows how to add audio experience to the gameplay. You will learn how to cue the audio and use the clips in the scenes.
Chapter 13, Profiling the Game Performance, masters the various editor debugging and profiling tools to define the performance issues.
Chapter 14, Packaging the Game, you will learn how to make an executable of the game for release. We also add a splash screen to show you're the boss, cook the game, and then use the project launcher to release it.
In order to be able to follow along with this book, you need to have a good foundation of C++, as the book mostly focuses on building an Unreal game using C++. You also need to have Unreal Engine installed and Visual Studio, and both be available for free.
If you are on a Mac or Linux, you'll definitely need another IDE to use with Unreal Engine, as Visual Studio is not supported on those platforms, but you'll still be able to go with the book smoothly.
Good game design and level design skills are great and will help, but they are not essential!
This book is for game developers who have basic knowledge of Unreal Engine and also have basic C++ scripting knowledge. This is ideal for those who want to take the leap from a casual game developer to a full-fledged professional game developer with Unreal Engine 4.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
You can download the code files by following these steps:
You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Mastering-Unreal-Engine-4X. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/MasteringUnrealEngine4X_ColorImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.
When you are about to create a C++ game using Unreal Engine, it means that you are going to create a big project. The two specific reasons for such a choice are: you are a core programmer and not familiar with the blueprints concept, or you want the game to run faster. Either way, you are about to get the right start here.
It's been said several times that C++-based games are quite a bit faster (10 times faster) than games made with blueprints. Although that was hearsay on the Unreal forums, the fact is that it is partly true. All games made with Unreal are equal in performance to those relying on the same technology and engine code base. However, when things get complex, it gets a little slower, and that speed difference is not as noticeable; it is something measured in milliseconds.
Starting a C++ project with Unreal is quite different, as it is not something that can be done inside the editor anymore. You'll need all the help of the IDE and, based on your platform, the setup will be different. My setup currently while writing this book is Windows 10, Unreal 4.10 and Visual Studio 2015. Apart from Google Documents, that's all that I need to create my data tables, and that's all that is needed!
By the end of this chapter, you will be able to:
The game we are going to create during the course of this book is called Bellz; it's definitely a word without a meaning. Its name came from the Hell Bells, as we are planning to put some unique bells around the maps!
The game is built with C++. While it is a C++ project, about 5% consists of necessary blueprints and other different graphs!
Bellz is a third-person RPG, where you have a mission loaded from Excel tables, weapons to use with different attributes, and evil enemies to escape from or to hunt. It looks simple, and the fact is, it is, but it holds all the needed elements to create a visually appealing AAA game. So that we stay on the same page, this game will take you step by step through the processes of:
The following is a screenshot of the final game:
With the goals set, let's get started by launching the Unreal launcher. If you already have an Unreal Editor instance running, that is not a problem; just choose to make a new project from within the File menu and that will launch the proper screen of the launcher. Otherwise inside the launcher, just hit the Launch button of the editor version you want. After a few seconds of loading, the editor project selection window will appear. Do the following:
If that was your first time creating a code project (which I guess is the case for the book's target audience), the project will take quite a time, it is not going to appear within a second like the other blueprint-based projects.
A C++-based project needs to copy some header files, build a Visual Studio solution/project (or Xcode if you are running on Mac), add the necessary code to the project, build files, inputs, the engine, and so on, and then finally run the Visual Studio command-line tool to compile and launch the project editor.
Now that you have a basic project, shall we go ahead and learn more about the C++ game project structure?
Yes!
But why?
Well, an Unreal project could increase to a crazy size at some point, especially if you are going to source-control your project using Git or SVN. You have to be wary about the space, as some free hosting services put a limit on the file type and file size you are using within your repository.
By opening the game project folder you will have these files and folders; some new files and folders might appear in the future as long as we keep adding stuff to the project. This is what I had by the end of the project:
While the folder is full of subfolders and files, it makes much more sense to break it all down. If you understand how the project directory works, it will be easy to understand how the game director works, and how you can optimize the size of the project.
But if you made a blueprint-based project, and at some point you wanted to convert it to a code file, you will find that the project options of the File menu display only one option for the Visual Studio, which is Generate Visual Studio Project.
Unreal Engine Project: An Unreal Engine project file that has the same name as the project and has the extension *.uproject. You can easily open the project using it, either by double-clicking on it or by browsing for it from the Unreal Launcher.Now we have a project set and running. However, that's not enough for us to start adding code, assets, and logic for the game. A game project has tons and tons of settings and options, which will have been set to default values when you create a new project, and every time you make a new game or project, you have to set those settings to specific options that fit your needs and your goals.
Accessing the project settings is very easy as you only have to click on the Project Settings button at the end of the Edit menu button.
First things first, I like to always set the overall information about my project at an early stage, so I don't have to worry about it later. From the Description section of the project settings, you can set the company name, and its homepage; also you can assign the logo for the project to be displayed on the launcher and description of the project and its name.
The most important part for this C++-based project is to set the copyright notice. By defining a piece of text here, it will be automatically added to all your newly created C++ files. So you have a copyright added to your code… Just in case!
Another important option to set is the map to be used as the default map for the game and for the editor. I agree that we don't have maps set yet but once you have a map, you need to set it inside the Maps & Modes section; so you make sure that every time you run the editor, you don't have to reload the map you want.
Finally, I would like to set the targeted platforms. I already know that my game will be running on PCs and consoles, so there is no need to label my game as an Android or iOS game for example. Therefore, you can just uncheck the untargeted platforms from the Supported Platforms section.
To access the editor settings, from the Edit menu, just choose Editor Preferences. If you are using a Mac, you might find it in a different place, usually it is called Preferences or Editor Preferences and it is listed under the Unreal Editor menu.
There is not much that needs to be changed within the editor settings, as it is mostly about personal, preferred settings while working with the editor. I don't mind sharing the few changes I made for the editor of Bellz, but feel free to ignore them and apply your preferred settings, or don't apply any editor settings at all if you prefer to keep it that way.
Under the Loading & Saving section of the General settings, I managed to disable the autosave option for any asset type; that way I make sure that the editor saves only on my demand, and I'll not get too many unnecessary files, keeping my project size as small as possible. Also, disabling the source control (if you are not using it, or you are using another source control system) is a good way to go with a smaller project!
From the Play section of the Level Editor settings, make sure you enable Game Gets Mouse Control; this way I make sure that the game has the advantage of using the mouse over the editor.
And that's it. There are lots of changes I used to make to the editor, but there were mostly related to changing the colors to fit my experience and keeping the overall visual look of the objects the same between all the applications I was using. For example, changing the color of selected objects to match the selected objects in Maya viewport, so I keep things consistent. But those two options are the important ones that have an impact on my experience while working.
In some cases, you might have an asset within an Unreal project that you want to use within another project. And because Unreal content is converted into .uasset files, it is not that easy to just copy assets from the Content folder of a project into another Content folder of another project.
For this game, we are about to create the basic animations of the default Unreal Engine mannequin character, to be used by my character. Therefore, by opening any of the Unreal projects and by selecting the required animation files, you can just right-click on them and choose Migrate and then choose the new project you want to copy assets to.
That way, all the assets with the required dependencies will be copied to the new project. However, achieving it by just doing a window-level copying will not guarantee you move all the required files. In my case, when I was copy animations the editor found that I needed to copy the character mesh, skeleton, and the materials as well. Those have been selected automatically for me and set alongside the targeted animation files.
Finally, a typical OS window will pop up to ask you to choose the destination folder/project you want to migrate the assets and all its dependencies to.
Now as a single-person project (me or you, we are both working as individuals now), you can't make the entire game all by yourself. In other words, time, and the goal of this book, do not allow us to do that. Thus, that's the reason behind relying on some free assets, or you might like to get some of it outsourced. It is all up to you.
For Bellz, I used a mix of assets provided by Epic games; they are free to use and you can get them from the launcher. The assets are labeled with Infinity Blade (yeah, those assets are a free giveaway from Epic and the developer of the game), and they are really top-quality assets.
While those assets look perfect, not that many animations come with the packages so I used some of the free animations provided by Epic and asked a friend to make some other animations for me to use.
A good exercise here is to follow the migrate process we discussed earlier in this chapter in order to migrate some of the custom animations I've made in the book's project, and move them into your project.
In order to get the packages installed, you have to download them first from the Marketplace section of your launcher, then you will find a button next to those packages that displays Add To Project. I've added warriors, enemies, weapons, and the grass environment to my project. Feel free to add them as well (I highly recommend them) or get your own assets.
There are three types of environment presented for free; you are free to pick the one you want. I just liked the grassy one. After making your decision about which to use of the free packages, all that you have to do is to hit the Add To Project button. Keep in mind, some of the Marketplace packages don't have the Add To Project button, and they have only a Create Project button; with those packages you'll need to create a whole new project in order to be able to use them or migrate some of their assets to your current project.
This will take you to a whole new section of the launcher, and you probably have never been there before. It displays all the valuable projects that could match this package. It is all about the engine version and the package version which usually have to match, and Epic might change this condition in the near future. Anyway, I made my choice as Bellz.
Now it will take some time to load and add the directories and the assets to your project. Go ahead and redo the process for the other packages you want to add to the project (the warriors, enemies, and weapons).
Keep in mind that, if you are using Windows, you don't have to relaunch the project. In a Windows version of the editor, once you add a package to the project through the launcher, you can locate them right away from within the editor. But if you are running Unreal on a Mac, you have to relaunch the editor in order to find the assets inside the project.
Feel free to take your time to check the characters, enemies, weapons, and the environments and all the animations provided by them. Also spend some time migrating any animations you want from the project sample that came with the book, and decide which assets you are going to use with your instance of Bellz, and delete any other unneeded assets, such as all other characters, enemies, and weapons. Those files are large, and will heavily increase your project size, so, it's a good idea to keep the project as clean as possible as we go.
When I was choosing my characters, I picked the bear as my main game enemy. The choice came as a result of several factors. First, I liked the two attack animations that the bear has, it is very strong and has great key poses. Second and most importantly, the bear has no idle, walk, or run animations, and it's a good opportunity to check some of the Unreal tricks of duplicating animations from a skeleton to another different skeleton. This is called animation retargeting.
By default, when you import an animation for the first time, you will be asked to either use an already made skeleton asset from within the project, or to import the asset skeleton and build a skeleton asset out of it. For several animations of the same character, you will keep reusing the skeleton asset, but once you import a different character it'll force Unreal to create its own skeleton structure asset.
Now, as you might have noticed, each enemy of the Infinity Blade assets has its own skeleton assets, and our main focus here is to somehow get an idle animation alongside the running and/or walking animation for the bear. As you noticed, the bear has only two animations!
Now if you check what the closest animal is in body structure and skeleton hierarchy to the bear (and included in the assets), you will find the wolf asset. This asset has all that we need and more, it is very similar to the bear, and it has walking and idle animations, alongside other attached animations. The goal now is to retarget and close the walk and idle animations of the wolf and use them with the bear. After we finish that, we will retarget the walk animation once more, and change its speed factor in order to make it look like a running animation (a run is just a fast walk, huh?!), and that will save us the time of creating animations or assets from scratch. It will even save us more time if we want to send the bear asset back to Maya or 3dsMax to add some more animations for it.
The retargeting process is very simple; you can consider it as the following steps:
