Hello,
I am creating WeaponPickup Actor.
In header file I have this:
void OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
void OnOverlapEnd(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex);
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Apperance", meta = (AllowPrivateAccess = "true"))
UBoxComponent* BoxComponent;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Apperance", meta = (AllowPrivateAccess = "true"))
class UStaticMeshComponent* BaseMesh;
And in cpp in the constructor this:
//Base mesh
BaseMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BaseMesh"));
BaseMesh->SetupAttachment(RootComponent);
//Collision
BoxComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxCollision"));
BoxComponent->SetupAttachment(BaseMesh);
BoxComponent->SetWorldScale3D(FVector(1.0f, 1.0f, 1.0f));
BoxComponent->SetWorldLocation(FVector(0.f, 0.f, 0.f));
BoxComponent->OnComponentBeginOverlap.AddDynamic(this, &AWeaponPickup::OnOverlapBegin);
BoxComponent->OnComponentEndOverlap.AddDynamic(this, &AWeaponPickup::OnOverlapEnd);
And at the end of the file two methods:
void AWeaponPickup::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Some debug message!"));
}
void AWeaponPickup::OnOverlapEnd(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex)
{
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Some debug message!"));
}
My problem is that this messages are never showed up I can walked into pickup, leave him and nothing happend. I checked BoxComponent and Collision is enabled (OverlapAll) and Generate Overlap Events is too enabled…