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

State machines


Traditionally, we would default to the AI Behavior Tree, which is available to anyone using UE4. However, in our scenario, we will break the job of Behavior Tree into components directly written in blueprint. So, the next thing we need to create is a way to maintain a state. Then, we can essentially create a state machine by updating the variable, allowing our AI to transition into different states by controlling the execution flow.

We will establish this using an event that will update our state when the conditions we specify are met. To start this off, let's continue to the next step!

  1. First, let's create a new Int variable in our AIController called State. This will maintain our current state within our state machine.

  2. We now need a new event, and we will call it NextRoute. So, upon right-clicking on the event graph and going under Add Event, we will notice Add New Event. Let's name this new event NextRoute.

  3. Now, after our assigned event ReceiveMoveCompleted, we should call NextRoute...