Recognizable Code

#What I recognized in the template code


#include "PositionReporter.h"

I recognized the include of the header file. Even though it’s not in main.cpp. This way the method definitions are declared before the definitions of the methods.

	// 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;

	// ...

The structure of the code is familiar to me with the namespacing of the class to the method. This would be the constructor of the class we just created.

// Called when the game starts
void UPositionReporter::BeginPlay()

	// ...

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

	// ...

Outside the course, I am familiar with how these works. In Javascript / P3 Java as well as when I worked in Unity. The TickComponent() would be called each frame. So any changes it might pick up on such as player movement / maybe you clicked on an event ect. It would know about it here and run the logic in that frame.

The BeginPlay() get’s ran only the first frame of when it’s instantiated. So lets say this was a shot fired by a super galatic spacehawk 3000 (random spaceship name). You could find the location of where that ship was, set it’s starting location in this spot via the location of your spaceship (with some padding of course). Then in your TickComponent() you would update the location fired in a direction straight from the super galatic spacehawk 3000.


#pragma once

I recognized #pragma once from this course, so this header file is only compiled once.

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "PositionReporter.generated.h"

I recognized these from also the course, as libraries this header file needs to import the Unreal Standard for header files. (my guess).

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )

The only thing i recognize about this, is this is a constant function call where the arguments are set to defaults.

class BUILDINGESCAPE_API UPositionReporter : public UActorComponent

	// Sets default values for this component's properties

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

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


I’m not really familiar with how the class is setup, my guess is the class is of type UActorComponent and inherits from BUILDINGESCAPE_API, since it appends public this makes this class public to the rest of the classes in the project.

The public section of the class i recognize from being a programmer, it allows the use of this class method outside of the class. So in this case the constructor.

The protected I believe means it’s public but cannot be changed or overridden. So BeginPlay() could be called outside the class but can’t be changed or overridden. (could be mistaken for a private method that can’t be overridden).

And then the private method just means it belongs to the class alone. So only this class will know about it’s version of TickComponent() which means, this class function can only have access to this function within this class and can’t be used in any other classes.

1 Like

Privacy & Terms