For some reason, I can not get the binded function to fire.
Here is the relevent code
Header File
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "PPlayerPlane.generated.h"
UCLASS()
class MYPROJECT_API APlayerPlane : public APawn
{
GENERATED_BODY()
public:
// Sets default values for this pawn's properties
APlayerPlane();
UPROPERTY(EditAnywhere, Category = "Components")
class UStaticMeshComponent* PlayerPlaneModel;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UFUNCTION()
void OnOverlap(
UPrimitiveComponent* OverlappedComp,
AActor* OtherActor,
UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex,
bool bFromSweep,
const FHitResult& SweepResult
);
};
and the cpp file
APlayerPlane::APlayerPlane()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
PlayerPlaneModel = CreateDefaultSubobject<UStaticMeshComponent>("Base Plane Model");
SetRootComponent( PlayerPlaneModel );
}
// Called when the game starts or when spawned
void APlayerPlane::BeginPlay()
{
Super::BeginPlay();
if ( !IsPendingKill() )
{
DirtyUtility :: Log( "About to bind function" );
PlayerPlaneModel -> OnComponentBeginOverlap.AddDynamic( this, &APlayerPlane :: OnOverlap );
}
}
void APlayerPlane :: OnOverlap (
UPrimitiveComponent* OverlappedComp,
AActor* OtherActor,
UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex,
bool bFromSweep,
const FHitResult& SweepResult )
{
DirtyUtility :: Log( "This has overlaped" );
}
Note that DirtyUtility :: Log is my own logging function.
I have made sure that all actors have generate overlapping events enabled
I have made sure that the function is marked as a UFUNCTION
I have made sure that the function is binded in begin play instead of the constructer.
I also make sure the object is marked for kill
When I run the game after compiling, the log does complain that function may not be a UFUNCTION or that the object is pending kill
And when the test cube I have setup for the actor overlaps with another object, nothing happens