Book Image

Unreal Engine 4 Scripting with C++ Cookbook

By : William Sherif, Stephen Whittle
Book Image

Unreal Engine 4 Scripting with C++ Cookbook

By: William Sherif, Stephen Whittle

Overview of this book

Unreal Engine 4 (UE4) is a complete suite of game development tools made by game developers, for game developers. With more than 100 practical recipes, this book is a guide showcasing techniques to use the power of C++ scripting while developing games with UE4. It will start with adding and editing C++ classes from within the Unreal Editor. It will delve into one of Unreal's primary strengths, the ability for designers to customize programmer-developed actors and components. It will help you understand the benefits of when and how to use C++ as the scripting tool. With a blend of task-oriented recipes, this book will provide actionable information about scripting games with UE4, and manipulating the game and the development environment using C++. Towards the end of the book, you will be empowered to become a top-notch developer with Unreal Engine 4 using C++ as the scripting language.
Table of Contents (19 chapters)
Unreal Engine 4 Scripting with C++ Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Creating a UInterface


UInterfaces are a pair of classes that work together to enable classes to exhibit polymorphic behavior among multiple class hierarchies. This recipe shows you the basic steps involved in creating a UInterface purely in code.

How to do it...

  1. UInterfaces don't show up inside the main class wizard within Unreal, so we'll need to add the class manually using Visual Studio.

  2. Right click on your Source folder inside Solution Explorer, and select Add | New Item.

  3. Select a .h file to start, and name it MyInterface.h.

  4. Make sure you change the directory for the item to be placed in from Intermediate to Source/ProjectName.

  5. Click on OK to create a new header file in your project folder.

  6. Repeat the steps in order to create MyInterface.cpp as your implementation file.

  7. Add the following code to the header file:

    #include "MyInterface.generated.h"
    /**  */
    UINTERFACE()
    class UE4COOKBOOK_API UMyInterface: public UInterface
    {
      GENERATED_BODY()
    };
    
    /**  */
    class UE4COOKBOOK_API IMyInterface
    {
     ...