Get errors when trying to use AddDynamic macro

PlatformTrigger.cpp

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

#include "TwinSticky.h"
#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; //check for null

	RootComponent = TriggerVolume;

	TriggerVolume->OnComponentBeginOverlap.AddDynamic(this, &APlatformTrigger::OnBoxBeginOverlap);
	TriggerVolume->OnComponentEndOverlap.AddDynamic(this, &APlatformTrigger::OnBoxEndOverlap);

//	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::OnBoxBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	UE_LOG(LogTemp, Warning, TEXT("ACTIVATED"));
}

void APlatformTrigger::OnBoxEndOverlap(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
	UE_LOG(LogTemp, Warning, TEXT("wont work either"));
}

PlatformTrigger.h

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

#pragma once

#include "GameFramework/Actor.h"
#include "PlatformTrigger.generated.h"

UCLASS()
class TWINSTICKY_API APlatformTrigger : public AActor
{
	GENERATED_BODY()
	
private:
	UPROPERTY(VisibleAnywhere)
	class UBoxComponent* TriggerVolume;

	UFUNCTION()
		void OnBoxBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);

	UFUNCTION()
		void OnBoxEndOverlap(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
public:	
	// Sets default values for this actor's properties
	APlatformTrigger();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

	
};

Errors:

Error	1	error C2664: 'void TBaseDynamicMulticastDelegate<FWeakObjectPtr,void,AActor *,UPrimitiveComponent *,int32,bool,const FHitResult &>::__Internal_AddDynamic<APlatformTrigger>(UserClass *,void (__cdecl APlatformTrigger::* )(AActor *,UPrimitiveComponent *,int32,bool,const FHitResult &),const TCHAR *)' : cannot convert argument 2 from 'void (__cdecl APlatformTrigger::* )(UPrimitiveComponent *,AActor *,UPrimitiveComponent *,int32,bool,const FHitResult &)' to 'void (__cdecl APlatformTrigger::* )(AActor *,UPrimitiveComponent *,int32,bool,const FHitResult &)'	C:\Users\dakot\OneDrive\Documents\Unreal Projects\TwinSticky\Source\TwinSticky\PlatformTrigger.cpp	19
Error	2	error C2664: 'void TBaseDynamicMulticastDelegate<FWeakObjectPtr,void,AActor *,UPrimitiveComponent *,int32>::__Internal_AddDynamic<APlatformTrigger>(UserClass *,void (__cdecl APlatformTrigger::* )(AActor *,UPrimitiveComponent *,int32),const TCHAR *)' : cannot convert argument 2 from 'void (__cdecl APlatformTrigger::* )(UPrimitiveComponent *,AActor *,UPrimitiveComponent *,int32)' to 'void (__cdecl APlatformTrigger::* )(AActor *,UPrimitiveComponent *,int32)'	C:\Users\dakot\OneDrive\Documents\Unreal Projects\TwinSticky\Source\TwinSticky\PlatformTrigger.cpp	20
Error	3	error : Failed to produce item: C:\Users\dakot\OneDrive\Documents\Unreal Projects\TwinSticky\Binaries\Win64\UE4Editor-TwinSticky-8933.dll	C:\Users\dakot\OneDrive\Documents\Unreal Projects\TwinSticky\Intermediate\ProjectFiles\ERROR
Error	4	error MSB3073: The command ""D:\Program Files\Epic Games\UE_4.8\Engine\Build\BatchFiles\Build.bat" TwinStickyEditor Win64 Development "C:\Users\dakot\OneDrive\Documents\Unreal Projects\TwinSticky\TwinSticky.uproject" -rocket" exited with code -1.	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets	38
	5	IntelliSense: no instance of function template "FComponentBeginOverlapSignature::__Internal_AddDynamic" matches the argument list
            argument types are: (APlatformTrigger *, void (APlatformTrigger::*)(UPrimitiveComponent *OverlappedComp, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult), const wchar_t [37])
            object type is: FComponentBeginOverlapSignature	c:\Users\dakot\OneDrive\Documents\Unreal Projects\TwinSticky\Source\TwinSticky\PlatformTrigger.cpp	19
	6	IntelliSense: no instance of function template "FComponentEndOverlapSignature::__Internal_AddDynamic" matches the argument list
            argument types are: (APlatformTrigger *, void (APlatformTrigger::*)(UPrimitiveComponent *OverlappedComp, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex), const wchar_t [35])
            object type is: FComponentEndOverlapSignature	c:\Users\dakot\OneDrive\Documents\Unreal Projects\TwinSticky\Source\TwinSticky\PlatformTrigger.cpp	20

I have no idea why this error is there. Using UE4.8.3 because it’s required for school.

Haven’t fixed it but I did fix some things: https://www.github.com/Greeley/TwinSticky

According to GitHub the signature of BeginOverlap should be

(AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)

And EndOverlap should be

(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);

I see the confusion here. The code @Greeley has is perfect but probably not for 4.8.3

I hope you managed to get it sorted.

Privacy & Terms