Unreal Engine v4.22.3
.h file
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Engine/TriggerVolume.h"
#include "TestFunctionality.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class MYPROJECT_API UTestFunctionality : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UTestFunctionality();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
private:
UPROPERTY(EditAnywhere, Category="Functionality")
ATriggerVolume* TriggeringArea;
};
.cpp file:
#include "TestFunctionality.h"
// Sets default values for this component's properties
UTestFunctionality::UTestFunctionality()
: TriggeringArea{nullptr}
{
// Set this component to be initialized when the game starts, and to be ticked every frame.
PrimaryComponentTick.bCanEverTick = true;
}
// Called when the game starts
void UTestFunctionality::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void UTestFunctionality::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}
Unreal Engine v4.26.1
.h file:
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Engine/TriggerVolume.h"
#include "TestFunctionality.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class TUTORIALPROJECT_API UTestFunctionality : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UTestFunctionality();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
private:
UPROPERTY(EditAnywhere, Category="Functionality")
ATriggerVolume* TriggeringArea;
};
.cpp file:
#include "TestFunctionality.h"
// Sets default values for this component's properties
UTestFunctionality::UTestFunctionality()
: TriggeringArea{nullptr}
{
// Set this component to be initialized when the game starts, and to be ticked every frame.
PrimaryComponentTick.bCanEverTick = true;
}
// Called when the game starts
void UTestFunctionality::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void UTestFunctionality::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}
//Note:
Essentially the same code, besides project naming convention.
with engine v4.22.3 the ATriggerVolume declaration is assignable, and not assignable with engine v4.26.1, through the editor.
I haven’t tried programatically, at some point that’ll happen, but I’m still learning and that’s probably chapter 26 and I’m on chapter 3.*