I am trying to code a Spawn Point class, but the actors I spawn are never destroyed after the game ends no matter how I try. I have destroyed them in game by pickup functionality and I am also destroying them within the Spawn point class by keeping a pointer to the spawned object and calling Destroy in EndPlay.
Each time I gain a new blueprint instance in the editor at the spawn location.
My spawn function:
if (PickUpToSpawn != NULL){
UWorld* const World = GetWorld();
if (World){
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.Instigator = Instigator;
FVector SpawnLocation = GetActorLocation();
FRotator SpawnRotation = GetActorRotation();
SpawnedPickUp = World->SpawnActor<APickUp>(PickUpToSpawn, SpawnLocation, SpawnRotation, SpawnParams);
Occupied = true;
}
}
SpawnedPickUp is just a private pointer with no editor/blueprint functionality. In EndPlay I simply test if Occupied is true and if it is call SpawnedPickUp->Destroy();
Why would a destroyed actor be created at all in the editor? And how can I stop it from happening?