Hey, your code works fine on my end. Though i use the Ctor for the SphereObject instantiation and i dont know where you put it.
However, doing a multicast to call the same object but different functions doesnt feel very useful. If you bind several other objects to it its fine then.
// in AMyClass.h
/*
UFUNCTION()
void Loot_Pickup(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
UFUNCTION()
void TZ_Enter(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
UPROPERTY()
USphereComponent* PCollider;
*/
AMyClass::AMyClass() // you could even use the objectinitializer version
{
PCollider = CreateDefaultSubobject<USphereComponent>(TEXT("Collider")); // Declares the Collision Sphere
PCollider->bGenerateOverlapEvents = true; // Allows the sphere to generate overlap events
PCollider->SetSphereRadius(200.f); // Sets the radius
PCollider->OnComponentBeginOverlap.AddDynamic(this, &AMyClass::TZ_Enter); //Function called from this class
PCollider->OnComponentBeginOverlap.AddDynamic(this, &AMyClass::Loot_Pickup);
PCollider->SetupAttachment(RootComponent); // Attaches the Collision Sphere to the root component of this actor
PCollider->SetHiddenInGame(false); // Shows the sphere in game (For debugging purposes)
}
void AMyClass::TZ_Enter(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
GEngine->AddOnScreenDebugMessage(-1, 3, FColor::Red, TEXT("TZ_ENTER"));
}
void AMyClass::Loot_Pickup(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
GEngine->AddOnScreenDebugMessage(-1, 3, FColor::Blue, TEXT("Loot_Pickup"));
}
Btw. are you sure the second is not called? Did you set breakpoints to make sure? Because you print in case your conditions is true otherwise nothing happened.