What I found from generated code

Let’s start with the cpp file!

#include “PostionReport.h”

This include is calling everything in the PositionReport header file.

// Sets default values for this component’s properties
UPostionReport::UPostionReport()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don’t need them.
PrimaryComponentTick.bCanEverTick = true;
}

We have the PositionReport class with and added U in front which is part of Unreal’s Syntax.
It has bCanEverTick to be true so whenever you use tick it can be called every frame.

// Called when the game starts
void UPostionReport::BeginPlay()
{
Super::BeginPlay();

}

Kinda like Start function in Unity C#


The :: is a Scope Resolution Operator. You can use a Scope Resolution Operator to access a global variable, to define a function outside it’s class, access multiple inheritances, and to access a class’s static variables.


Here is where we will write all the code we want to start when the game starts

// Called every frame
void UPostionReport::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

}

Here is where we can write called that we want to be called every frame.
Also there is a pointer in this function. ThisTickFunction is the pointer and it is pointing to FActorComponentTickFunction

I’m not exactly sure what Super is? Can someone explain what Super does?

Next is the header file!

#pragma once

#include “CoreMinimal.h”
#include “Components/ActorComponent.h”
#include “PostionReport.generated.h”

ALWAYS place any generated files at the bottom of all the preprocessor directives!
We are including CoreMinimal header file, and ActorComponent header file that is found in the Component folder.

I’m not sure what #pragma once does. Can someone explain what #pragma once does?

CLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UPostionReport : public UActorComponent
{
GENERATED_BODY()

Here is where I start getting lost. I’m not sure what ClassGroup is doing or what is meta doing. All I can gather is that this is a class. xD

Is the PositionReport inheriting the actor component here?

public:
// Sets default values for this component’s properties
UPostionReport();

Creates the PositionReport Class.

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

Creates the BeginPlay class.

public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};

Calls the TickComponent Class.

That is what I found from the generated code.

Privacy & Terms