I’m trying to create a “pressure plate” kind of setup (derived from AActor), where a BP event will fire when the player moves onto a square but nothing seems to be happening. Where am I going wrong here?
.h
UPROPERTY(EditAnywhere, Category = "Pressure plate")
UBoxComponent* PlateTrigger;
UFUNCTION()
void OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
UFUNCTION()
void OnOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
.cpp
ABasePressurePlate::ABasePressurePlate()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
SetReplicates(true);
PlateMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Pressure plate mesh"));
SetRootComponent(PlateMesh);
PlateTrigger = CreateDefaultSubobject<UBoxComponent>(TEXT("Pressure plate trigger"));
PlateTrigger->OnComponentBeginOverlap.AddDynamic(this, &ABasePressurePlate::OnOverlapBegin);
PlateTrigger->OnComponentEndOverlap.AddDynamic(this, &ABasePressurePlate::OnOverlapEnd);
}
void ABasePressurePlate::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
UE_LOG(LogTemp, Warning, TEXT("OnOverlapBegin()"))
}
void ABasePressurePlate::OnOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
UE_LOG(LogTemp, Warning, TEXT("OnOverlapEnd()"))
}