Book Image

Learning C++ by creating games with UE4

By : William Sherif
Book Image

Learning C++ by creating games with UE4

By: William Sherif

Overview of this book

Table of Contents (19 chapters)
Learning C++ by Creating Games with UE4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Variables and Memory
Index

Creating a player entity


In order to create an onscreen representation of the player, we'll need to derive from the Character class in Unreal.

Inheriting from UE4 GameFramework classes

UE4 makes it easy to inherit from the base framework classes. All you have to do is perform the following steps:

  1. Open your project in the UE4 editor.

  2. Go to File and then select Add Code to Project....

    Navigating to File | Add Code To Project... will allow you to derive from any of the UE4 GameFramework classes

  3. From here, choose the base class you want to derive from. You have Character, Pawn, Actor, and so on, but for now, we will derive from Character:

    Select the UE4 class you want to derive from

  4. Click on Next > to get this dialog box, where you name the class. I named my player's class Avatar.

  5. Finally, click on Create Class to create the class in code, as shown in the preceding screenshot.

Let UE4 refresh your Visual Studio project when it asks you. Open the new Avatar.h file from the Solution Explorer.

The code...