How to do it...

  1. Open up your project within the Unreal Editor and click on the Add New button in Content Browser:

  1. Select New C++ Class...:

  1. In the dialog that opens, select Actor from the list:

  1. Give your Actor a name, such as MyFirstActor, and then click on OK to launch Visual Studio:
By convention, class names for Actor subclasses begin with an A. When using this class creation wizard, make sure you don't prefix your class with A, as the engine automatically adds the prefix for you.

  1. When Visual Studio loads, you should see something very similar to the following listing:
// MyFirstActor.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyFirstActor.generated.h"

UCLASS()
class CHAPTER_04_API AMyFirstActor : public AActor
{
GENERATED_BODY()

public:
// Sets default values for this actor's properties
AMyFirstActor();

protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;

public:
// Called every frame
virtual void Tick(float DeltaTime) override;

};

// MyFirstActor.cpp

#include "MyFirstActor.h"

// Sets default values
AMyFirstActor::AMyFirstActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void AMyFirstActor::BeginPlay()
{
Super::BeginPlay();

}

// Called every frame
void AMyFirstActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

}