We're now going to create a new C++ class with the following steps:
To do this, from the Unreal editor, click on File | New C++ Class. We'll be creating an Actor class, so select Actor as the base class. Actors are the objects that are placed in the scene (anything from meshes, to lights, to sounds, and more).
Next, enter a name for your new class, such as
MyNewActor
. Hit Create Class. After it adds the files to the project, openMyNewActor.h
in Visual Studio. When you create a new class using this interface, it will generate both a header file and a source file for your class.Let's just make our actor print a message to the output log when we start our game. To do this, we'll use the
BeginPlay
event.BeginPlay
is called once the game has started (in a multiplayer game, this might be called after an initial countdown, but in our case, it will be called immediately).The
MyNewActor.h
file (which should already be open at this point) should contain the following code...