Book Image

Unreal Engine 4 AI Programming Essentials

By : Jie Feng, Peter Newton
Book Image

Unreal Engine 4 AI Programming Essentials

By: Jie Feng, Peter Newton

Overview of this book

Unreal Engine is a powerful game development engine that provides rich functionalities to create 2D and 3D games. Developers have the opportunity to build cross-platform mobile and desktop games from scratch. This book will show you how to apply artificial intelligence (AI) techniques to your Unreal project using blueprints as your scripting language. You will start with an introduction to AI, and learn how it is applied to gaming. Then you'll jump right in and create a simple AI bot and apply basic behaviors to allow it to move randomly. As you progress, you'll find out how to implement randomness and probability traits. Using NavMesh, you will impart navigation components such as character movement, MoveTo nodes, settings, and world objects, and implement Behavior Trees. At the end of the book, you will troubleshoot any issues that might crop up while building the game.
Table of Contents (16 chapters)
Unreal Engine 4 AI Programming Essentials
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Preface

Artificial Intelligence (AI) is an essential part of any game. It makes the virtual world we create more immersive and fun to play in. Game AI is different from the general scientific AI that we know; it is more targeted to solve key problems in game design, including navigation, which is how a nonplayer character (NPC) should move from one point to another and avoid obstacles; decision making, which is how to perform certain actions based on different situations; and environment sensing, which is the ability to understand what exists in the environment and what its status is. These techniques make it possible to create a dynamic and realistic gameplay so that the players will be more engaged in the world that is created for them.

Game AI is complicated and brings a lot of challenges if you want to develop on your own. Unreal Engine 4 is a powerful game engine that provides rich functionalities to create cross-platform 3D and 2D games. It is well known for its advanced graphics and highly customizable components. Now, it is free to use and open source, which makes it one of the most popular game engines out there. Unreal Engine 4 comes with a complete suite of tools for game AI, including NavMesh, Behavior Trees, and Environment Query System. With these tools in hand, it is much easier to bring AI to your games. For game designers, you can even use a visual scripting tool called Blueprints to build your game logic, including AI, by just connecting nodes and without even writing a single line of code.

This book is our effort to introduce these wonderful tools in Unreal Engine 4 to build game AI to game creators who are interested in making their virtual world more interesting. It will cover all the components we have mentioned and show you how to use each tool to build different character behaviors and combine them to create more complex scenes.

We can't wait to see what you will create!

What this book covers

Chapter 1, Introduction to Game AI?, introduces the basic idea of AI and how it directly affects and enhances the gaming experience. You will learn the differences between the traditional and game-specific goals of AI.

Chapter 2, Creating Basic AI, helps you create your first AI step by step and talks about the techniques we will demonstrate along the way. We will dive right into Unreal Engine 4, using the bare components needed to create a single state with random movement for your AI.

Chapter 3, Adding Randomness and Probability, teaches you how to create random and probability techniques that can be used to add randomness, chance, and character to AI, which will make the game unpredictable and more interesting. We will cover how these are used within Unreal Engine 4.

Chapter 4, Introducing Movement, explains how to introduce movement to our AI characters within Unreal Engine 4. Path Finding will be used to allow our character to intelligently navigate within a level.

Chapter 5, Giving AI Choices, explains how to introduce autonomous behavior to our characters using Behavior Trees. Behavior Trees are a methodology that allows you to construct your AI logic visually in a tree structure and can be reused in different characters.

Chapter 6, How Does Our AI Sense?, explains how to use the different components available within Unreal Engine 4 to enable our AI to sense other AI and the pawns we will place within the world.

Chapter 7, More Advanced Movement, focuses on flocking and more advanced path-following behaviors. Flocking allows us to create group behaviors for several AI characters.

Chapter 8, Creating Patrol, Chase, and Attack AI, combines some of the components we used in the previous chapters, including AI Sense and Movement, to have our AI character navigate. Then, we will apply randomness to the time that the AI character will spend chasing after the characters it detects.

Chapter 9, What Have We Learned?, briefly glances over the previous chapters. We will also talk about additional examples of what we can achieve with these combined lessons.

What you need for this book

All you need is Unreal Engine 4.7.0, and you can download it from https://www.unrealengine.com.

Who this book is for

This book is for programmers and artists who want to expand their knowledge of game AI in relation to Unreal Engine 4. It is recommended that you have some experience of exploring Unreal Engine 4 prior to this book because we will jump straight into game AI.

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: "Now, place a comment around this and name it Chase Hero."

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: "If you're in Unreal Engine and you navigate to the Modes panel under Volumes, you'll see NavMeshBoundsVolume."

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 , 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:

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

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

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

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

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

  7. Click on Code Download.

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

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/ LearningUnrealEngineAIProgramming_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 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 , and we will do our best to address the problem.