I’m new to c++ and can’t quite get a handle on delegate binding. I’m trying to write a class derived from UBoxComponent
that binds to the OnComponentBeginOverlap
dynamic multicast delegate.
I also have a dynamic array of primitive components declared for this class. What I would like this component to do is maintain an index of any and all components from other actors it is overlapping with. Here’s what I’ve got so far:
my h:
#pragma once
#include "Components/BoxComponent.h"
#include "FloorSensor.generated.h"
UCLASS()
class MYPROJECT_API UFloorSensor : public UBoxComponent
{
GENERATED_BODY()
public:
UFloorSensor(const FObjectInitializer& ObjectInitializer);
FComponentBeginOverlapSignature StartOverlappingDelegate;
UFUNCTION()
void StartOverlappingDelegate(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
bool bIsOverlapping;
// Stores overlapping components whose parent actor implements certain interface
TArray<UPrimitiveComponent*> OverlappingComponents;
};
my ccp:
#include "MyProject.h"
#include "FloorSensor.h"
UFloorSensor::UFloorSensor(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
void UFloorSensor::StartOverlappingDelegate(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
}
I’m getting several errors:
error C2365: 'UFloorSensor::StartOverlappingDelegate' : redefinition; previous definition was 'data member'
error C2064: term does not evaluate to a function taking 5 arguments
I’d be hugely grateful for any help here.