Your problem is that you are trying to assign a newly defined delegate to an already defined one, one that is expecting different parameters than your newly defined delegate. In order to assign a delegate to your componentbeginoverlap, you should be using a function that has the following parameters;
onCollide(class UPrimitiveComponent* OverlappedComponent, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
You don’t need a redefinition. Just use the one that already exists.
I know that this error occurs when unreal can’t convert from one variable type to another. I also know that my current data type is void, but what am I supposed to convert this void to?
XD.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "Test2.h"
#include "XD.h"
// Sets default values
AXD::AXD()
{
// 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;
newMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Static Mesh"));
newBox = CreateDefaultSubobject<UBoxComponent>(TEXT("Collision Box"));
newBox->OnComponentBeginOverlap.AddDynamic(this, &AXD::onCollide);
}
// Called when the game starts or when spawned
void AXD::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AXD::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
XD.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Actor.h"
#include "XD.generated.h"
#define DECLARE_DYNAMIC_MULTICAST_DELEGATE(a);
#define DECLARE_DYNAMIC_MULTICAST_DELEGATE(b);
#define DECLARE_DYNAMIC_MULTICAST_DELEGATE(c);
UCLASS()
class TEST2_API AXD : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AXD();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
UFUNCTION()
void onCollide(UPrimitiveComponent* a, class AActor* b, class UPrimitiveComponent* c)
{
Destroy();
}
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UPROPERTY(EditAnywhere)
UStaticMeshComponent* newMesh;
UPROPERTY(EditAnywhere)
UBoxComponent* newBox;
};