Book Image

Unreal Engine 4.X By Example

By : Benjamin Carnall
Book Image

Unreal Engine 4.X By Example

By: Benjamin Carnall

Overview of this book

With Unreal Engine 4 being made free to use, for any keen game developer it is quickly becoming the most popular game engine in today’s development industry. The engine offers a rich feature set that can be customized and built upon through the use of C++. This book will cover how to work with Unreal Engine’s tool set all the way from the basics of the editor and the visual scripting system blueprint to the in-depth low-level creation of content using C++. This book will provide you with the skills you need to create feature-rich, captivating, and refined game titles with Unreal Engine 4. This book will take you through the creation of four unique game projects, designed so that you will be ready to apply the engine’s rich development capabilities. You will learn not only to take advantage of the visual tools of the engine, but also the vast and powerful programming feature set of Unreal Engine 4.
Table of Contents (17 chapters)
Unreal Engine 4.X By Example
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Creating a custom service using C++


Now that we have finished creating the behavior tree for our AI, it is about time we go about setting the blackboard keys that a large amount of our logic is based on. We are going to do this with a service. As stated previously, a service is something that will take place at a certain frequency or tick. Services act as a way to update AI information and states during runtime from the behavior tree. We have created enough BT assets using blueprint, so it is time we create one in C++! The purpose of this service is to check an area around the AI for an ABMCharacter, if one is found, set it as the target for the AI to follow.

Start by creating a new C++ class via the wizard, this time the class will inherit from BTService. Ensure you do not inherit from BTService_BlueprintBase as that abstraction is to only be used by blueprints. Call this new class BMAgroCheck. Once the engine has generated the new code files, navigate to BMAgroCheck.h.

Defining the BMArgoCheck...