Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Unreal Engine 4 AI Programming Essentials
Unreal Engine 4 AI Programming Essentials

Unreal Engine 4 AI Programming Essentials: Create responsive and intelligent game AI using Blueprints in Unreal Engine 4

eBook
€8.99 €23.99
Paperback
€29.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Unreal Engine 4 AI Programming Essentials

Chapter 2. Creating Basic AI

In this chapter, we will create our first AI step-by-step and talk about the techniques that we demonstrate along the way. So today, we will dive right into Unreal Engine 4 using the bare components needed to create a single state with random movement for your AI. We will then review what we've done, the changes we can make, and the disadvantages of the techniques demonstrated.

This chapter will cover:

  • Setting up our project
  • Creating the AIController
  • Sending instructions to Pawn with the AIController
  • Creating small blueprint scripts to assist in navigation

Goal

Our goal for this chapter is to place an AI character in the level that has the blueprint to instruct it to move randomly and indefinitely. We will demonstrate multiple techniques throughout this chapter to get a good grasp of some really basic AI techniques commonly featured in titles. These techniques are listed as follows:

  • First, we want to place an AI character, Hero, in the level that has the blueprint to instruct it to move randomly and indefinitely. We will achieve this by first creating a new third-person project and naming it appropriately. We will then use the default pawn provided from the sample content as the bot. We will create an AIController to control our pawn. We will then provide our AIController with instructions to move our bot randomly and indefinitely.
  • Second, we want to make the AI character follow some basic path. For example, we'll have the AI move along the walls in one direction. We can take our existing project and modify the AIController with new instructions...

Setting up the project

Let's open up Unreal Engine 4! We will begin with the first process of creating a new project.

Note

We will use Unreal Engine 4.6.0 throughout this book. The instructions may vary per version. We will present the idea behind our actions as we demonstrate them using Unreal Engine 4; so, hopefully, you will be able to translate the instructions as you see fit.

Here, we will use the Third Person Shooter template, which allows us to easily observe how the character moves in the environment. Perform the following steps:

  1. Go to the New Project window if you aren't there already:
    Setting up the project
  2. Select the Third Person blueprint project:
    Setting up the project
  3. Name your project as you see fit; I've named mine ImprovedAI. Then, hit Create Project in the lower-right corner of the window.

Environment

Even though we are using the Third Person blueprint template, these techniques can be used on other templates as well. You must adapt what you learn here. That being said, what you start to understand is that...

Using our new AIController class

Ever notice how one player can be any character they desire? This is the hierarchy that creates the pawn and the controller. The controller is what the player inherits after waiting for some time in the game lobby. It is used to manage the input and connection from the player. This class comes with additional functions to help navigate the bot and the ability to assign a Behavior Tree to the controller. In this demonstration, we will cover some of the basics of the AIController class.

Assigning the AIController class

So, now that we have what we need to create an AI, we will assign the MyController class to the MyCharacter base. To do so, go to the Defaults section within the MyCharacter blueprint. Search for AIController Class and set it to MyController, as shown in the following screenshot:

Assigning the AIController class

When a character isn't possessed, it will automatically be possessed by AIController. So, with the change we just made, the default AIController class that possesses...

Reviewing the current progress

You can wipe the sweat from your forehead; the hard work has yet to begin. So, what have we done so far?

  • We've set up our AI project
  • We've set up our pawn with our new AIController
  • We've sent instructions to our pawn using AIController

We're halfway there. This simple setup allows us to put all our instructions on our AIController, which will possess the pawn we created from the sample content. The AIController is assigned to pawns, which means that multiple pawns can share the same AIController.

As we can see, our AI now runs indefinitely. Perfect! Let's move on to the second section of this chapter!

Adding the challenge

Now, we will add line traces to the AI character. In our demonstration, we will use traces to detect the wall in front of the pawn. Other examples of using traces in the AI include Line of Sight checking, getting surface rotation, and getting nearby actors.

Let's go back to Unreal Engine Level Editor and look within Content Browser. Perform the following steps:

  1. Rename our MyController blueprint Hero; this will act as the player in this scenario.
  2. Open our Hero blueprint and go to the EventGraph section.
  3. Now, remove every node except the Event Tick and Move to Location nodes. We will replace these with new blueprint scripting:
    Adding the challenge

    Blueprint after removing unnecessary nodes

  4. Pull from the return exec pin on the Event Tick node and create a Delay node.
  5. Set the Duration value to .05 so that it will update relatively fast.
  6. Now, we have to get the location from the pawn to create line traces. We will also use the right vector to face the pawn to the right from the pawn's current...

Goal


Our goal for this chapter is to place an AI character in the level that has the blueprint to instruct it to move randomly and indefinitely. We will demonstrate multiple techniques throughout this chapter to get a good grasp of some really basic AI techniques commonly featured in titles. These techniques are listed as follows:

  • First, we want to place an AI character, Hero, in the level that has the blueprint to instruct it to move randomly and indefinitely. We will achieve this by first creating a new third-person project and naming it appropriately. We will then use the default pawn provided from the sample content as the bot. We will create an AIController to control our pawn. We will then provide our AIController with instructions to move our bot randomly and indefinitely.

  • Second, we want to make the AI character follow some basic path. For example, we'll have the AI move along the walls in one direction. We can take our existing project and modify the AIController with new instructions...

Setting up the project


Let's open up Unreal Engine 4! We will begin with the first process of creating a new project.

Note

We will use Unreal Engine 4.6.0 throughout this book. The instructions may vary per version. We will present the idea behind our actions as we demonstrate them using Unreal Engine 4; so, hopefully, you will be able to translate the instructions as you see fit.

Here, we will use the Third Person Shooter template, which allows us to easily observe how the character moves in the environment. Perform the following steps:

  1. Go to the New Project window if you aren't there already:

  2. Select the Third Person blueprint project:

  3. Name your project as you see fit; I've named mine ImprovedAI. Then, hit Create Project in the lower-right corner of the window.

Environment

Even though we are using the Third Person blueprint template, these techniques can be used on other templates as well. You must adapt what you learn here. That being said, what you start to understand is that these techniques...

Using our new AIController class


Ever notice how one player can be any character they desire? This is the hierarchy that creates the pawn and the controller. The controller is what the player inherits after waiting for some time in the game lobby. It is used to manage the input and connection from the player. This class comes with additional functions to help navigate the bot and the ability to assign a Behavior Tree to the controller. In this demonstration, we will cover some of the basics of the AIController class.

Assigning the AIController class

So, now that we have what we need to create an AI, we will assign the MyController class to the MyCharacter base. To do so, go to the Defaults section within the MyCharacter blueprint. Search for AIController Class and set it to MyController, as shown in the following screenshot:

When a character isn't possessed, it will automatically be possessed by AIController. So, with the change we just made, the default AIController class that possesses our...

Reviewing the current progress


You can wipe the sweat from your forehead; the hard work has yet to begin. So, what have we done so far?

  • We've set up our AI project

  • We've set up our pawn with our new AIController

  • We've sent instructions to our pawn using AIController

We're halfway there. This simple setup allows us to put all our instructions on our AIController, which will possess the pawn we created from the sample content. The AIController is assigned to pawns, which means that multiple pawns can share the same AIController.

As we can see, our AI now runs indefinitely. Perfect! Let's move on to the second section of this chapter!

Left arrow icon Right arrow icon

Key benefits

  • Understand and apply your Game AI better through various projects such as adding randomness and probability, and introducing movement
  • Configure and debug Game AI logic using multiple methodologies
  • Bridge the gap between your knowledge and Game AI in Unreal Engine 4

Description

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.

Who is this book for?

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

What you will learn

  • ? Understand the fundamental components of game AI within Unreal Engine 4
  • ? Skillfully introduce game AI within Unreal Engine 4
  • ? Configure, customize, and assign navigation and AI components to your pawn
  • ? Create, debug, and analyze game AI behavior
  • ? Design responsive game AI using the Behavior Tree methodology
  • ? Create smart objects designed to interact with AI
  • ? Utilize advanced AI features within your project to maximize the user experience

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Mar 18, 2016
Length: 188 pages
Edition : 1st
Language : English
ISBN-13 : 9781784396558
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Mar 18, 2016
Length: 188 pages
Edition : 1st
Language : English
ISBN-13 : 9781784396558
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 107.97
Unreal Engine Game Development Blueprints
€41.99
3D Game Design with Unreal Engine 4 and Blender
€35.99
Unreal Engine 4 AI Programming Essentials
€29.99
Total 107.97 Stars icon
Banner background image

Table of Contents

10 Chapters
1. Introduction to Game AI Chevron down icon Chevron up icon
2. Creating Basic AI Chevron down icon Chevron up icon
3. Adding Randomness and Probability Chevron down icon Chevron up icon
4. Introducing Movement Chevron down icon Chevron up icon
5. Giving AI Choices Chevron down icon Chevron up icon
6. How Does Our AI Sense? Chevron down icon Chevron up icon
7. More Advanced Movement Chevron down icon Chevron up icon
8. Creating Patrol, Chase, and Attack AI Chevron down icon Chevron up icon
9. What Have We Learned? Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.6
(12 Ratings)
5 star 25%
4 star 16.7%
3 star 0%
2 star 8.3%
1 star 50%
Filter icon Filter
Top Reviews

Filter reviews by




Andrew McLennan-Murray Jul 22, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book gives a good introduction to the built in AI systems in UE4. Besides this book, Epic's documentation, and some user created docs, you'll be hard pressed to find more in one text. After going through the material I realized some of what I needed to do was not built in to UE. I reached out directly to the author. He was extremely knowledgeable and helpful in guiding me toward a solution and more resources.
Amazon Verified review Amazon
Peter Newton Apr 16, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
If anyone has any issues with my product, email me@peterlnewton.com for any explanations or concerns. I will not be able to revise this copy of the book as this is now allowed by the publisher. When I first wrote this I just began as an instructor, so I apologies as the teaching quality is sub-par to what I capable of doing now. I have learned a lot since I first wrote this book over nearly 2 years ago.
Amazon Verified review Amazon
Hugo May 15, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Unreal engine is a powerful AAA cross platform game engine that enable you to develop high quality games, this book teach me how to use blueprints visual tool to build my game logic, this is amazing how much you can achieve, Unreal already have a great set of tools that provide common AI, this book explain some of them, enabling me to apply their in my game easily without any line of code, I like to code, but to implement AI only in code I would have to spend much more time and effort. The book starts from foundations of AI in game development, after that you will start from basic techniques, teaching how these features work, giving you the idea of where to use it and the possibilities that you achieve combining these features with other to create more complex interesting behaviors like movements, randomness, probabilities, behavior trees, sensors, path followings and others. This can make your game so much fun and immersive, your players will have a much better gaming experience and you be proud of your work. This book has a great structure and if you never worked with game AI programming in Unreal Engine you will feel comfortable as you read this because the author has explained almost from scratch all the concepts and techniques, I think this way you learn for sure and be able to extend what you know, the game AI is almost limitless.
Amazon Verified review Amazon
Fernando M. Jul 18, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Good explanation of all AI background in blueprint domain. The book is synthetic and essential describes only one example for each argument,but effective.
Amazon Verified review Amazon
cookie Feb 16, 2021
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Saw some upset comment, thus understand their feelings. I decided to give a read given that I realize my BP was rusty understanding level, the author did display some good technique like for instance using the the FIND with the Give Access Node and Cast <3personChar>. I find this bewildering as there is no explanation but after spending 8hours of researching, begin to understand the logic behind it. It basically just to compare the CharArrray Get access variable to the Possess Pawn Cast <3PersonChar> and provide access to the waypoint actors for the "Approved" pawn.Another given example was class = class. If I was a beginner i probably wun understand this either. It basically to boolean if the class IS equal to the matched class actor.Hope that this will not discourage the author as it covers the basics of AI in technical way, and I appreciate the techniques they shared. Hopefully they can come up another Book on AI with better explanation.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.