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

Pawn detection


To give our pawn the most up-to-date information, we need to create an event that will catch and respond to the sensory update events from the AI Perception component. We will establish this by creating a new event that is solely responsible for processing detected pawns. Here are the steps:

  1. Let's right-click anywhere and go under Add Event. From there, we want to add a custom event, and we will name the new event Detected Enemies. We have to also create a new actor array parameter named Detected Actors to hold the array of Updated Actors.

  2. Now, in the next step, we need to recompile a blueprint to call the AIController and the Detected Enemies function from our OnPerceptionUpdated event:

  3. In the next steps, we will handle the transitions between different states. For example, we can be in the default state and find a new enemy. From there, we need to stop the current movement and move toward the detected enemy. If we lose sight of an enemy that we've been chasing for a specific...