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
$9.99 $29.99
Paperback
$38.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
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
Estimated delivery fee Deliver to Indonesia

Standard delivery 10 - 13 business days

$12.95

Premium delivery 5 - 8 business days

$45.95
(Includes tracking information)

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 : 9781784393120
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Indonesia

Standard delivery 10 - 13 business days

$12.95

Premium delivery 5 - 8 business days

$45.95
(Includes tracking information)

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.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
$199.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
$279.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 $ 140.97
Unreal Engine Game Development Blueprints
$54.99
3D Game Design with Unreal Engine 4 and Blender
$46.99
Unreal Engine 4 AI Programming Essentials
$38.99
Total $ 140.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

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela