Hi,
Anyone that have an idea whats wrong with this code? the TriggerEnter is never called when my player is trying to pickup the object.
Thanks
Falcula
// Sets default values
APickup::APickup()
{
// 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;
PickUpRoot = CreateDefaultSubobject<USceneComponent>(TEXT("Pickup root"));
RootComponent = PickUpRoot;
PickUpMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Pickup mesh"));
PickUpMesh->AttachToComponent(PickUpRoot,FAttachmentTransformRules::SnapToTargetNotIncludingScale);
PickUpBox = CreateDefaultSubobject<UBoxComponent>(TEXT("PickupBox"));
PickUpBox->SetWorldScale3D(FVector(1.0f, 1.0f, 1.0f));
PickUpBox->bGenerateOverlapEvents = true;
PickUpBox->OnComponentBeginOverlap.AddDynamic(this, &APickup::TriggerEnter);
PickUpBox->AttachToComponent(PickUpRoot, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
UE_LOG(LogTemp, Warning, TEXT("constructor"));
}
void APickup::TriggerEnter(class UPrimitiveComponent* HitComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
UE_LOG(LogTemp, Warning, TEXT("DESTROY"));
Destroy();
}