Skip to content
Snippets Groups Projects
Commit 31f4cef2 authored by Ehret's avatar Ehret
Browse files

fix minor bug creating too many Representations when changing something in...

fix minor bug creating too many Representations when changing something in another component at runtime, cause the construction script to run again
parent b274216c
Branches master
No related tags found
No related merge requests found
......@@ -63,8 +63,10 @@ FVASoundSource::FVASoundSource(UVASourceComponent* ParentComponent, TArray<AVARe
}
// Show graphical representation
FActorSpawnParameters SpawnParameters;
SpawnParameters.bAllowDuringConstructionScript = true;
SoundSourceRepresentation = ParentComponent->GetWorld()->SpawnActor<AVASoundSourceRepresentation>(
AVASoundSourceRepresentation::StaticClass());
AVASoundSourceRepresentation::StaticClass(), SpawnParameters);
SoundSourceRepresentation->SetPosition(ParentComponent->GetPosition());
......@@ -96,6 +98,14 @@ FVASoundSource::FVASoundSource(UVASourceComponent* ParentComponent, TArray<AVARe
}
}
FVASoundSource::~FVASoundSource()
{
if(SoundSourceRepresentation && SoundSourceRepresentation->IsValidLowLevel())
{
SoundSourceRepresentation->Destroy();
}
}
// ****************************************************************** //
......
......@@ -17,6 +17,7 @@ public:
// Initialization
FVASoundSource(UVASourceComponent* ParentComponent, TArray<AVAReflectionWall*> WallArray);
~FVASoundSource();
// Setter
void SetPosition(FVector PosN);
......
......@@ -35,6 +35,11 @@ void UVASourceComponent::BeginPlay()
}
void UVASourceComponent::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
SoundSource.Reset();
}
// Called every frame
void UVASourceComponent::TickComponent(const float DeltaTime, const ELevelTick TickType,
......
......@@ -225,6 +225,8 @@ protected:
// Called when the game starts
void BeginPlay() override;
void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
// initialize Sound Source with the settings set //
void Initialize();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment