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

Only $11.99/month after trial. Cancel anytime.

Mastering Unreal Engine 4.X
Mastering Unreal Engine 4.X
Mastering Unreal Engine 4.X
Ebook679 pages6 hours

Mastering Unreal Engine 4.X

Rating: 0 out of 5 stars

()

Read preview

About this ebook

About This Book
  • Build an entire AAA game level throughout the book
  • Take your C++ scripting skills to the next level and use them extensively to build the game
  • An advanced practical guide with a tutorial style approach that will help you make the best of Unreal engine 4
Who This Book Is For

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.

LanguageEnglish
Release dateJun 30, 2016
ISBN9781785885228
Mastering Unreal Engine 4.X
Author

Muhammad A.Moniem

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 being 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 was able to contribute as a full-time or part-time employee or freelancer to 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. Finally, he was able to establish his own one-person game company/team as a part-time independent developer. A lot of his indie games got recognition or have been finalists at international indie game events, such as IGF, Indie Showcase, IGC, and Tokyo Game Show. He has written another Unreal Engine book before and he has also designed an amazing website, www.mamoniem.com. 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.

Related to Mastering Unreal Engine 4.X

Related ebooks

Applications & Software For You

View More

Related articles

Reviews for Mastering Unreal Engine 4.X

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Mastering Unreal Engine 4.X - Muhammad A.Moniem

    Table of Contents

    Mastering Unreal Engine 4.X

    Credits

    About the Author

    Acknowledgments

    About the Reviewer

    www.PacktPub.com

    eBooks, discount offers, and more

    Why subscribe?

    Preface

    What this book covers

    What you need for this book

    Who this book is for

    Conventions

    Reader feedback

    Customer support

    Downloading the example code

    Downloading the color images of this book

    Errata

    Piracy

    Questions

    1. Preparing for a Big Project

    Overview of the game

    Creating a C++ project

    The project settings

    The editor settings

    Mapping the inputs

    Migrating assets

    Using MarketPlace assets

    Retargeting animations

    Summary

    2. Setting Up Your Warrior

    The code project

    Creating the C++ class

    Editing and adding code

    The Gladiator header (.h) file

    The Gladiator source (.cpp) file

    The includes

    The constructor

    BeginPlay

    SetupPlayerInputComponent

    Jump

    StopJumping

    OnAttack

    OnPostAttack

    OnChangeWeapon

    TurnAtRate

    LookUpAtRate

    OnSetPlayerController

    OnChangeHealthByAmount

    MoveForward

    MoveRight

    Compiling the code

    Animation assets

    Adding sockets to the skeleton

    Creating the blend space

    The animation blueprint

    Building the blueprint

    Adding the blueprint to the GameMode

    Summary

    3. Designing Your Playground

    The art of level design

    Placing assets into the world

    Using brushes to enhance level design

    Adding lights to the level

    Building lightmaps for a level

    Creating water surfaces

    Player Start

    The navigation mesh

    Summary

    4. The Road to Thinkable AI

    The overall idea

    The AI assets

    Behavior Tree

    BTTask

    BTService

    Blackboard

    The animation blueprint

    Building the C++ logic

    EnemyAIController

    EnemyAIController.h

    EnemyAIController.cpp

    Enemy

    Enemy.h

    Enemy.cpp

    Building the behavior tree

    Creating the blueprint

    Adding notifies

    What else?

    Summary

    5. Adding Collectables

    The idea behind collectables

    The base class

    PickupBase.h

    PickupBase.cpp

    The coin class

    CoinPickup.h

    CoinPickup.cpp

    Making it collectable

    Building the blueprint

    Going forward

    Summary

    6. The Magic of Particles

    The particles editor

    Toolbar

    The viewport panel

    The emitters panel

    The details panel

    Particle system

    Thumbnail

    LOD

    Bounds

    Delay

    Macro UV

    Occlusion

    Materials

    The particle emitter

    Particle

    Cascade

    Particle modules

    Cascade

    Curve Editor

    Interpolation modes

    Organizing curves

    Adding curves to the graph

    Removing curves from the graph

    Organizing the curve editor with tabs

    Spawning particles

    Changing parameters at runtime

    Summary

    7. Enhancing the Visual Quality

    The lightmass

    The Swarm Agent

    The ambient occlusion

    AO settings

    Lightmass settings

    World Settings

    Importance volume settings

    The post process project settings

    The post process volume

    The properties

    The available effects

    Reflection Capture

    Reflection Capture actors

    The fog effects

    Atmospheric Fog

    Adding it

    Exponential Height Fog

    Adding it

    Summary

    8. Cinematics and In-Game Cutscenes

    Matinee actor (cinematic actor)

    Matinee Editor

    Groups

    Tracks

    Bellz cinematic

    The animated fog

    Color

    Animating exponential height fog

    Saving the cinematic as video

    Summary

    9. Implementing the Game UI

    UMG as Unreal's UI system

    The game UI widget

    UMG Designer

    The Toggle mode

    Palette

    The hierarchy

    Animations

    Canvas

    The Details panel

    Constructing the UI

    Adding animations to the UI

    Connecting the UI with the game logic

    What else?

    Summary

    10. Save the Game Progress

    Building the SaveGame class

    Saving and loading game data in C++

    The *.sav file

    Saving and loading game data in blueprints

    Summary

    11. Controlling Gameplay via Data Tables

    Data table sheets

    Creating the data table asset

    Creating a data structure

    Blueprint data structure

    C++ data structure

    GameDataTables.h

    GameDataTables.cpp

    Reading from data tables

    Reading data through C++

    Reading through blueprints

    Summary

    12. Ear Candy

    Importing audio files

    Sound assets

    Dialogue Voice

    Dialogue Wave

    Media sound wave

    Reverb effect

    Sound attenuation

    Sound Class

    Sound cue

    Sound mixes

    Sound cue editor

    Audio volumes

    Playing sound effects

    Summary

    13. Profiling the Game Performance

    The blueprint debugger

    The Collision Analyzer

    The console

    The FPS charts

    The view modes and visualizers

    The GPU visualizer

    The Device Manager

    Device Profiles

    Summary

    14. Packaging the Game

    Preparing the project for building

    Packaging settings

    Maps & Modes settings

    Description settings

    Platform settings

    Adding different screens

    Packaging the game

    Cooking the content

    Project Launcher and DLCs

    Packaging a release

    Packaging a patch or DLC

    Summary

    Index

    Mastering Unreal Engine 4.X


    Mastering Unreal Engine 4.X

    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

    Credits

    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

    About the Author

    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.

    Acknowledgments

    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…!

    About the Reviewer

    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.

    www.PacktPub.com

    eBooks, discount offers, and more

    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 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.

    Why subscribe?

    Fully searchable across every book published by Packt

    Copy and paste, print, and bookmark content

    On demand and accessible via a web browser

    Preface

    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.

    What this book covers

    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.

    What you need for this book

    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!

    Who this book is for

    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.

    Conventions

    In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

    Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: The game we are going to create during the course of this book is called Bellz.

    A block of code is set as follows:

    UCLASS(config = Game)

    class AGladiator : public ACharacter

    {

      GENERATED_BODY()

    New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: Otherwise inside the launcher, just hit the Launch button of the editor version you want.

    Note

    Warnings or important notes appear in a box like this.

    Tip

    Tips and tricks appear like this.

    Reader feedback

    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 <feedback@packtpub.com>, 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.

    Customer support

    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.

    Downloading the example code

    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:

    Log in or register to our website using your e-mail address and password.

    Hover the mouse pointer on the SUPPORT tab at the top.

    Click on Code Downloads & Errata.

    Enter the name of the book in the Search box.

    Select the book for which you're looking to download the code files.

    Choose from the drop-down menu where you purchased this book from.

    Click on Code Download.

    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:

    WinRAR / 7-Zip for Windows

    Zipeg / iZip / UnRarX for Mac

    7-Zip / PeaZip for Linux

    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!

    Downloading the color images of this book

    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.

    Errata

    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

    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 <copyright@packtpub.com> with a link to the suspected pirated material.

    We appreciate your help in protecting our authors and our ability to bring you valuable content.

    Questions

    If you have a problem with any aspect of this book, you can contact us at <questions@packtpub.com>, and we will do our best to address the problem.

    Chapter 1. Preparing for a Big Project

    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:

    Start a new Unreal Engine C++ project from scratch

    Set the project and editor settings to match your needs

    Map any input device to match your game design

    Import and export assets in and out of the Unreal Editor

    Migrate assets between the different Unreal projects

    Retarget animations between the different skeletons

    Add the required modules and header files to the project code

    Overview of the game

    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:

    Starting a C++ project based on a blank template.

    Creating a player controller.

    Building enemies, behavior trees, and blackboards.

    Creating animation graphs and retargeting different animations.

    Loading game-required data from the design data tables.

    Adding camera animations and cut scenes to the game.

    Adding audio effects and visual effects to the game.

    Creating and building appealing maps.

    Optimizing the game as much as possible.

    Debugging the game performance.

    Packaging the game to players.

    The following is a screenshot of the final game:

    Creating a C++ project

    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:

    Switch to the New Project tab.

    Under New Project, switch to the C++ subtab.

    Choose a Basic Code project type.

    Set the target to Desktop/Console as that's our target!

    Set the quality to Maximum Quality.

    Remove the starter content, it will not be useful at all.

    Give your project a name, but make sure to remember that name, as a lot of the code will be using it. Mine is called Bellz. I would say go ahead and name your project with the same name so you can easily follow along with the tutorial without any confusion or naming conflicts.

    Finally hit Create Project!

    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

    Enjoying the preview?
    Page 1 of 1