Hi community
I am trying to make an actor be able to fire off an ActorBeginOverlap event in c++. I keep getting errors and due to my inexperience with c++, I am unable to identify what needs fixing and how to fix it.
My code is below:
My c++ file
// Fill out your copyright notice in the Description page of Project Settings.
#include "PlatformTrigger.h"
#include "Components/BoxComponent.h"
// Sets default values
APlatformTrigger::APlatformTrigger()
{
// 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;
TriggerVolume = CreateDefaultSubobject<UBoxComponent>(FName("TriggerVolume"));
if (!ensure(TriggerVolume != nullptr)) return;
RootComponent = TriggerVolume;
TriggerVolume->OnComponentBeginOverlap.AddDynamic(this, &APlatformTrigger::OnOverlapBegin);
}
// Called when the game starts or when spawned
void APlatformTrigger::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APlatformTrigger::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void APlatformTrigger::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
{
UE_LOG(LogTemp, Warning, TEXT("Activated"));
}
And my header file
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "PlatformTrigger.generated.h"
UCLASS()
class PUZZLEPLATFORM_API APlatformTrigger : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
APlatformTrigger();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
private:
UPROPERTY(VisibleAnywhere)
class UBoxComponent* TriggerVolume;
UFUNCTION()
{
void OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
};