Class created from DefaultPawn class has nothing in the c++ file.

I am trying to create a new class to be my “EnemyPawn” class, but wanted to utilize the built in movement component of the DefaultPawn class instead of the Pawn class. However when I do this, the .cpp file has nothing in it except for the ‘include’ of the header file.

For example, this is the contents of the header file:

#pragma once

#include “CoreMinimal.h”
#include “GameFramework/DefaultPawn.h”

#include “Mob.generated.h”

UCLASS()
class BREADBOY_API AMob : public ADefaultPawn
{
GENERATED_BODY()

};

And this is the entire contents of the .cpp file:
#include “Mob.h”

When I would normally expect the .cpp file to have something like:

#include ”Mob.h”

AMob::AMob()

{

PrimaryActorTick.bCanEverTick = true;

}



void AMob::BeginPlay()

{

Super::BeginPlay();

}

Is this the expected behaviour? I tried adding in these functions like the constructor and beginplay manually but they just error. Any guidance appreciated.

Edit:
I may just go with using character class for my enemies to simplify things, but would still be good to know to understand why it does this. If you can point to some documentation or something that explains it that works too, couldn’t find what I was looking for on that note.

Yes, this is totally valid.

It’s simply a definition of a class that extends another but doesn’t override any function (including the constructor). In this case if any function is called it will simply call the parents class version. The .cpp file with the include is still required because otherwise your header file would nowhere be used and the class wouldn’t exist.

If you add the methods like in your example, you will also need to add the definition to the header file. Like

UCLASS()
class BREADBOY_API AMob : public ADefaultPawn
{
GENERATED_BODY()

public:
    AMob();
    void BeginPlay() override;
};

What IDE are you using? I can only recommend using Jetbrains Rider as it has a lot of useful code completion stuff and so on, which really helps if you are not so confident in C++.