I have custom component:
void UObjectSpawner::InitializeComponent()
{
Super::InitializeComponent();
if (Check)
{
UWorld* const World = ();
if (World)
{
if (Object)
{
SpawnedObject = World->SpawnActor<AActor>(Object, GetComponentLocation() + OffsetPosition.GetLocation(), GetComponentRotation() + OffsetPosition.Rotator());
}
}
}
}
// Called every frame
void UObjectSpawner::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction )
{
Super::TickComponent( DeltaTime, TickType, ThisTickFunction );
if (!doOnce)
{
if (SpawnedObject)
{
SpawnedObject->SetActorScale3D(OffsetPosition.GetScale3D());
}
doOnce = true;
}
}
This component must spawn BPs from other BP. But it spawning object every time i change property(like Construction script).
How to remove previous spawned object (Destroy() - dont help)? I dont want to disable this because it’s helpful.
And, you can see in code, i apply scale after game starts inside Tick. Is it possible to apply it somehow in InitializeComponent()?
P.S. Sorry for my English.