Download

AddDynamic doesn't match the argument list

Hi everyone, I am new to unreal engine c++ programming and I am getting this error when trying to add an overlap dynamic to my game, currently the script is:



// Fill out your copyright notice in the Description page of Project Settings.


#include "FlorSwitch.h"

// Sets default values
AFlorSwitch::AFlorSwitch()
{
     // 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;

    TriggerBox = CreateDefaultSubobject<UBoxComponent>(TEXT("TriggerBox"));
    RootComponent = TriggerBox;

    TriggerBox->OnComponentBeginOverlap.AddDynamic(this, &AFlorSwitch::OnOverlapBegin);
    TriggerBox->OnComponentEndOverlap.AddDynamic(this, &AFlorSwitch::OnOverlapEnd);

    FloorSwitch = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("FloorSwitch"));
    FloorSwitch->SetupAttachment(GetRootComponent());

    Door = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Door")); 
    Door->SetupAttachment(GetRootComponent());

}

// Called when the game starts or when spawned
void AFlorSwitch::BeginPlay(){
    Super::BeginPlay();

}

// Called every frame
void AFlorSwitch::Tick(float DeltaTime){
    Super::Tick(DeltaTime);

}

void AFlorSwitch::OnOverlapBegin(
        UPrimitiveComponent OnComponentBeginOverlap, 
        UPrimitiveComponent* OverlappedComponent, 
        AActor* OtherActor,
        UPrimitiveComponent* OtherComp, 
        int32 OtherBodyIndex, 
        bool bFromSweep, 
        const FHitResult& SweepResult
    ){
    UE_LOG(LogTemp, Warning, TEXT("OverLap Begin"))
}

void AFlorSwitch::OnOverlapEnd(
        UPrimitiveComponent OnComponentEndOverlap,
        UPrimitiveComponent* OverlappedComponent,
        AActor* OtherActor,
        UPrimitiveComponent* OtherComp,
        int32 OtherBodyIndex
    )
{
    UE_LOG(LogTemp, Warning, TEXT("OverLap End"))
}


And this is the error log:

Error (active) E0304 no instance of function template “FComponentBeginOverlapSignature::__Internal_AddDynamic” matches the argument list line 15

Error (active) E0304 no instance of function template “FComponentEndOverlapSignature::__Internal_AddDynamic” matches the argument list line 16

Error Missing ‘*’ in Expected a pointer type MyProject line 41

If anyone can help my thanks in advance.

The error message speaks for itself; your delegate functions’ signatures of OnOverlapBegin and OnOverlapEnd don’t match the expected function signature.
Your delegate functions must match the expected signature so the engine can send you the correct data.
The error in your case seems to be the first argument *UPrimitiveComponent OnComponentBeginOverlap, *which essentially states you’re expecting a pass by value of an UPrimitiveComponent. Remove that and it should work.