So am having a truble getting a sound to play.
When the player overlaps the Actor it suposed to play the sound and then get destroyd.
But i can`t get it to play on demand, only when the game starts.
is the code:
In my Actor
// .h
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Audio Component")
TSubobjectPtr <UAudioComponent> AudioComp;
// .cpp
// Constructor
AudioComp = PCIP.CreateDefaultSubobject<UAudioComponent>(this, TEXT("In-World Audio Pickup Sound"));
if (AudioComp)
{
AudioComp->AttachParent = RootComponent;
AudioComp->bAutoActivate = false; // with this true the sounds play at spawn (game starts)
}
void AInWorldPlayerPickUp::ReceiveActorBeginOverlap(class AActor* OtherActor)
{
Super::ReceiveActorBeginOverlap(OtherActor);
AMyProjectPlayerClass* TheOverlapingActor = Cast<AMyProjectPlayerClass>(OtherActor);
if (TheOverlapingActor)
{
AudioComp->Activate(true);
AudioComp->Play(0.0f); // Sound dont play.
if (GEngine)
{
FString TmpStr = "OVERLAP ! ! ! ! WITH: ";
TmpStr += OtherActor->GetName();
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, TmpStr);
}
Destroy(true);
}
}
Thanks for any help.