23,99 €
Blueprints Visual Scripting for Unreal Engine is a step-by-step approach to building a fully functional game, one system at a time. Starting with a basic First Person Shooter template, each chapter will extend the prototype to create an increasingly complex and robust game experience. You will progress from creating basic shooting mechanics to gradually more complex systems that will generate user interface elements and intelligent enemy behavior. Focusing on universally applicable skills, the expertise you will develop in utilizing Blueprints can translate to other types of genres.
By the time you finish the book, you will have a fully functional First Person Shooter game and the skills necessary to expand on the game to develop an entertaining, memorable experience for your players.
From making customizations to player movement to creating new AI and game mechanics from scratch, you will discover everything you need to know to get started with game development using Blueprints and Unreal Engine 4.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 261
Veröffentlichungsjahr: 2015
Copyright © 2015 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: July 2015
Production reference: 1210715
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-601-8
www.packtpub.com
Author
Brenden Sewell
Reviewers
Faris Ansari
Scott Hafner
Marcin Kamiński
Alankar Pradhan
Matt Sutherlin
Commissioning Editor
Neil Alexander
Acquisition Editor
Vivek Anantharaman
Content Development Editor
Divij Kotian
Technical Editor
Anushree Arun Tendulkar
Copy Editors
Hiral Bhat
Vikrant Phadke
Project Coordinator
Neha Bhatnagar
Proofreader
Safis Editing
Indexer
Rekha Nair
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
Brenden Sewell is a lead game designer at E-Line Media, and has spent the last 5 years designing and creating games that are both fun to play and have educational or social impact. He has been building games since 2002, when Neverwinter Nights taught him an invaluable lesson about the expressive power of game design. In 2010, he graduated with a degree in cognitive science from Indiana University. Since then, he has focused on enhancing his own craft of game design while harnessing its power to do good in the world, and exposing more people to the joy the profession holds.
I would like to thank the following people for contributing to this book and making it a reality: Steve Swink (@steveswink), Jake Martin, Demetrius Comes, and Graeme Bayless for providing me the right mentorship to elevate me in my design practice; Logan Barnett (@logan_barnett) and David Koontz (@dkoontz) for pushing my knowledge of scripting to become a more versatile developer; the Packt Publishing staff and my technical reviewers for helping me to make this book a reality; the Unreal development community for being supportive and informative as we all endeavor to master this technology together; and my supremely supportive girlfriend Michelle, my parents who made this all possible, and all of my incredible friends for enriching my life.
Faris Ansari is an IT professional from Pakistan, who has skills and interest in Unity 3D, Unreal Engine, Cocos2d, the Allegro library, OpenGL, and other game development environments. He started his career as a game developer and worked on successful games that generated huge revenues. He also possesses the skills required for, and takes on new challenges while, working on new technologies, especially open source technologies.
Faris has reviewed the book Learning NGUI for Unity.
His hobbies consist of playing games, learning new things, and watching movies. He is very interested in working with fellow coworkers and friends on innovative ideas. His favorite saying is, "Every professional was once a beginner."
Feel free to contact him and discuss something innovative. He can be reached on LinkedIn at https://www.linkedin.com/in/farisansari.
I would like to thank my friends and family for their continuous support and help.
Scott Hafner is a professional game designer with over 10 years of experience in the video game industry. Over the course of his career, he has worked as a producer, game designer, and level designer on a range of platforms and genres, including MMOs, third-person shooters, and RPGs.
I would like to thank my fianceé for her continued encouragement and support in all that I do!
Marcin Kamiński is working for CTAdventure as a senior programmer and has his own company, Digital Hussars. Previously, he worked for Artifex Mundi, CI Game, and Vivid Games. His main fields of expertise are artificial intelligence and network programming. For 14 years, he has helped develop great games for PCs, consoles, and mobiles.
Marcin was also a reviewer of the books Unity iOS Essentials and Unity 2D Game Development Cookbook.
Alankar Pradhan hails from Mumbai, Maharashtra. He did his schooling from I.E.S.'s CPV High School. He is an ambitious person who loves interacting with new people, dancing, kickboxing, traveling, spending leisure time with friends, and playing games on PCs and mobiles. Games have always been a passion in his life. More than just playing games, how things worked was his main curiosity. Hence, he decided to pursue his career in this. Alankar completed his BSc honors in software development from Sheffield Hallam University, UK. He has done his master's in video game programming and management (video game director; BAC+5 equivalent) from DSK Supinfogame, where he undertook industry-oriented projects to increase his skill sets and gave his best to do so. Alankar worked as a game programming intern at Walt Disney, India. During his internship, he was working on a live project called Hitout Heroes. His name was added to the credits due to his noticeable work accomplished. He also interned as a game programmer with DSK Green Ice Games, and then went on to work as a video game programmer on a game targeted at PCs and consoles. This game, Death God University (D.G.U), was released on July 1, 2015. Another project he is working on is The Forsaken Mountains.
Alankar has worked on many small projects in teams as well as individually to sharpen his own skills in various languages, such as C#, C++, Java, Unreal scripting, Python, Lua, Groovy/Grails, HTML5/CSS and so on. He is familiar with engines such as Unity3D, Unreal Development Kit, and Visual Studio and SDKs such as NetBeans, Eclipse, and Wintermute. In 2013, his dissertation work on Comparison between Python and Lua in Gaming Industry got published as a book. He has worked with Packt Publishing previously as a technical reviewer of Creating E-Learning Games With Unity and Learning Unreal Engine iOS Game Development.
Other than this, Alankar likes to read, listen to music, and write poems and short stories at times. He has his own website at http://alan.poetrycraze.com, where he posts his poems. He has also published a book, The Art Of Lost Words, which is available on Amazon.com.
His e-mail ID is <[email protected]>. You can visit his portfolio site at alankarpradhan.wix.com/my-portfolio or contact him on Facebook at www.facebook.com/alankar.pradhan.
We are so often caught up in our aim that we forget to appreciate the journey, especially the people we meet on the way. Appreciation is a wonderful feeling, and it's way better if we don't overlook it. I hereby like to take this opportunity to acknowledge the people who directed me and inspired me in this initiative.
I would like to express my sincere thanks to my parents, who always instilled and believed in me. I am also thankful to my friends for their constant support and encouraging words that helped me reach this level.
Last but not least, I would like to thank all the people who are directly or indirectly involved in this book and helped me in some way or another.
Matt Sutherlin has been working in the games industry over the last decade, where he's served roles ranging from a QA and scripter to an engine programmer and a technical artist. Most recently, he has had a strong focus on graphics technology, working on engine renderers, art pipelines, and shaders for AAA titles such as Heroes of the Storm and Halo 5: Guardians.
I would like to thank my wife, Megan, and parents, Mike and Mary Lynn, for years of support, patience, and understanding; I wouldn't be where I am without you. I'd also like to thank Alan Wolfe for being an unending stream of cool programming tricks and insightful algorithms and for generally being a really great friend.
For support files and downloads related to your book, please visit www.PacktPub.com.
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.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
Game engines, such as Unreal Engine 4—as the tools that power the creation of the commercial games we love to play—are becoming increasingly accessible to both experienced and novice game developers outside of the traditional studio environment. Previous versions of Unreal Engine have powered many of the most popular console and PC games released over the last decade, and the newest version contains the tools for funneling this power into the hands of as many aspiring developers as possible. The most transformative of these tools is the Blueprints Visual Scripting system, which allows people who are not full-time programmers to create and implement the mechanics, interfaces, and interactions of a game.
Taking a step-by-step approach, this book will guide you through the process of using the visual nodes that make up Blueprint behavior, and link them together to create game mechanics, user interfaces, and more. In this process, you will be learning all the skills you need to get started with developing games in Unreal Engine 4 using Blueprints.
Starting with a basic first-person shooter template, each chapter will extend the prototype to create an increasingly complex and robust game experience. You will progress from creating basic shooting mechanics to gradually more complex systems that will generate user interface elements and intelligent enemy behavior. By focusing on universally applicable skills, the expertise you will develop in utilizing Blueprints can translate to other types of genres. By the time you finish this book, you will have a fully functional first-person shooter and the skills necessary to expand on the game to develop an entertaining, memorable experience for your players.
Chapter 1, Object Interaction with Blueprints, begins the book by covering how to bring new objects into a level to help build the world in which the game will be set. We move on to manipulating materials on objects, first through the object editor, and then by triggering during runtime via Blueprints.
Chapter 2, Enhancing Player Abilities, teaches you how to use Blueprints to generate new objects during gameplay, and link actions in Blueprints to player control inputs. You also learn to create Blueprints that allow objects to react to collisions with our generated projectiles.
Chapter 3, Creating Screen UI Elements, demonstrates setting up a Graphical User Interface (GUI) that will track the player's health, stamina, ammo, and current objective. Here, you learn how to set up a basic user interface using Unreal's GUI editor and how to use Blueprints to link the interface to the gameplay values.
Chapter 4, Creating Constraints and Gameplay Objectives, covers how to constrain the player's abilities, define the gameplay objectives for a level, and track those objectives via Blueprints that interact with the GUI elements created in the previous chapter. We walk through setting up collectible ammo packs that will refill the ammo of the player's gun, as well as utilizing the level Blueprint to define a win condition for our game.
Chapter 5, Making Moving Enemies with AI, is a crucial chapter that covers how to create an enemy zombie AI that will pursue the player around the level. We walk through setting up a navigation mesh on our level, and see how to use Blueprints to get enemies to traverse between patrol points.
Chapter 6, Upgrading the AI Enemies, shows how to create a compelling experience by modifying the zombie AI to have states in order to give the zombies a little more intelligence. In this chapter, we set up the patrol, searching, and attack states for the zombies using visual and auditory detection. Additionally, we explore how to make new enemies appear gradually, as the game is playing.
Chapter 7, Tracking Game States and Applying Finishing Touches, adds the finishing touches necessary to make our game a complete experience, before we finalize our game for release. In this chapter, we create rounds that will make the game increasingly difficult, game saves so that the player can save their progress and return, and player death to make the game's challenge meaningful.
Chapter 8, Building and Publishing, covers how to optimize graphics settings to get our game performing and looking at its best. Then, we explain how to create a sharable build of the game, and share some advice on how to continue progressing past the confines of this book on your way to becoming an accomplished game developer!
This book is an Unreal Engine 4-focused title, which means you only need a copy of Unreal Engine to get started. Unreal Engine 4 can be downloaded for free from https://www.unrealengine.com/, and comes with everything you need to follow along with the book. This book was made using version 4.7.6 of Unreal Engine 4, and as such, it does not account for features added or removed in subsequent versions of the software.
Whether you are brand new to game development or just unexposed to Unreal Engine 4's Blueprint Visual Scripting system, this is a great place to start learning how to build complex game mechanics quickly and easily without writing any text code. No programming experience required!
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: "I named the project BlueprintScripting and stored it in the default Unreal Projects folder for OS X."
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: " Now click on the Library tab, find the yellow Install button (as seen in the following screenshot), and click on it."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
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 from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. 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.
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/6018OT_ColoredImages.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 setting out to develop a game, one of the first steps toward exploring your idea is to build a prototype. Fortunately, Unreal Engine 4 and Blueprints make it easier than ever to quickly get the essential gameplay functionality working so that you can start testing your ideas sooner. To develop some familiarity with the Unreal editor and Blueprints, we will begin by prototyping simple gameplay mechanics using some default assets and a couple of Blueprints.
In this chapter, we will cover the following topics:
Before we can begin setting up gameplay elements, we need to create a project that will contain the content of our game. To access Unreal Engine 4 and begin setting up our project, we must first open the Epic Games Launcher, which can be downloaded from the Unreal Engine 4 website (https://www.unrealengine.com/). From the Epic Games Launcher, click on the tab labeled Unreal Engine. If you are using Unreal Engine on your computer for the first time, you will see a grayed out-button labeled Not Installed. Along the left-hand side of the launcher, you will see options.
The Library tab is the location where you will be able to access the versions of the engine you have installed and the projects you have built. Now click on the Library tab, find the yellow Install button (as seen in the following screenshot), and click on it:
When the engine has finished installing, the Install buttons will change to Launch buttons, as shown in the following screenshot. Click on any of the Launchbuttons to open the engine.
Once you click on Launch, you will be presented with the Unreal Project Browser. This will by default take you to the Projects tab, which will show you a thumbnail view of all the projects you have created, as well as any sample projects you might choose to install. For our purposes, we want to start a new project, so click on the tab labeled New Project.
From the New Project tab, you can select a template that will give you the initial assets to use for your game; or you can choose to start a blank project. You will see two subtabs under the New Project tab, labeled Blueprint and C++. Creating a project from the content within the Blueprint tab will start your project with a basic set of behavior built using Blueprints. The C++ tab is used to create projects where at least some of the core types of behavior of the game are going to be built using the C++ programming language. Since we quickly want to get a prototype first-person shooter up and running without having to build the basic controls from scratch, we should ensure that we have the tab labeled Blueprint selected. Then we choose the First Person template, as shown here:
The next step is to adjust the project settings to our liking. The three gray boxes below the template selector allow us to select the class of hardware we are targeting (desktop/console or mobile/tablet), the graphics scalability, and whether we want to create our project with or without starter content. Leave these settings at their default values (Desktop/Console, Maximum Quality, and With Starter Content). Below these, you will see a folder path field used to designate where you would like to store your project on your hard drive, and a name field to input the name by which your project will be known. I named the project BlueprintScripting and stored it in the default Unreal Projects folder for OS X, as shown in this screenshot:
Now that we have a template selected and the project settings set up the way we like, we can create the project. To do so, click on the green Create Project button. After the engine is done with initializing the assets and setting up your project, Unreal Editor will open Level Editor, where you can create and view levels, place and modify objects, and test your game as you modify it.
Pressing the Play button, as shown in the following screenshot, along the top of the toolbar, will allow you to try the default gameplay that comes built into the First Person template. This includes player movement, shooting a simple projectile, and using projectiles to apply force to primitive box objects. In play mode, the Play button will be replaced with a Pause button and a Stop button. You can press the Pause button to temporarily halt the play session, which can be useful when you want to explore the properties of an interaction or actor that you just encountered during gameplay. Pressing the Stop button will end the play session and take you back to editing mode. Go ahead and try playing the game before we continue.
Now we want to start adding our own objects to the level. The central panel you see in Level Editor is known as 3D Viewport. Aviewport allows you to see the 3D content of the game, and it is important that you become familiar with navigating inside this panel. The viewport can be navigated by moving the camera around using a combination of mouse buttons and its movement. Holding down the left mouse button and dragging the mouse pointer inside the viewport moves the camera view forward and backward, or left and right. Holding down the right mouse button and moving the mouse allows you to look around by rotating the camera. Finally, holding down either the middle mouse button or a combination of both the left and right mouse buttons will allow you to drag the camera up and down.
The simplest kind of object that can be dragged into the game world in Unreal Engine 4 is called an actor. An actor is a basic object with no inherent behavior other than the ability to be rotated, moved, and scaled, but it can be expanded to include more complex behavior by attaching components. Our goal will be to create a simple target actor that will change color when shot with the included gun and projectile. We can create a simple actor by going to the Modes panel. With the Place tab selected, click on Basic and then drag the object called Cylinder into the 3D Viewport. This will create a new cylinder actor and place it in our level. You should see the actor in the 3D Viewport as well as in the Scene Outliner panel, where it will be named Cylinder by default. Right-click on this object in the Scene Outliner panel, go to Edit, and then select Rename. Rename the Cylinder object to CylinderTarget, as shown here:
Earlier, we set for ourselves the goal of changing the color of the cylinder when it is hit by a projectile. To do so, we will need to change the actor's material. A material is an asset that can be added to an actor's mesh (which defines the physical shape of the actor) to create its look. You can think of a material as paint applied on top of an actor's mesh or shape. Since an actor's material determines its color, one method of changing the color of an actor is to replace its material with a material of a different color. To do this, we will first be creating a material of our own. It will make an actor appear red.
We can start by creating a new folder inside the FirstPersonBP directory and calling it Materials. Navigate to the newly created folder and right-click inside empty space in the content browser, which will generate a new asset creation popup. From here, select Material to create a new material asset. You will be prompted to give the new material a name, which I have chosen to call TargetRed.
Double-click on TargetRed to open a new editor tab for editing the material, like this:
You are now looking at Material Editor, which shares many features and conventions with Blueprints. The center of this screen is called the grid, and this is