4.10 Deleted Actor scene outliner

Hi,
I’m trying to spawn some actor every seconds.
But some of them appear but some of them doesn’t appear …

Here is my code:

void ASpawnZombie::SpawnEnemy(TSubclassOf<AAIEnemy> Enemy)
{
	//Get the location of the enemy's home and create a random location around this home
	FVector Location = GetActorLocation(); 
	uint32 rand = FMath::RandRange(-1000, 1000);
	Location.X += rand;
	rand = FMath::RandRange(-1000, 1000);
	Location.Y += rand;

	FRotator Rotation = FRotator(0, 0, 0);



	UWorld* const World = GetWorld(); //GetWorld

	if (World)
	{
		FActorSpawnParameters SpawnInfo; //Spawn information
		SpawnInfo.bNoFail = true;
		SpawnInfo.Owner = this;
		SpawnInfo.Instigator = Instigator;

		//Spawn an enemy with the correct location and rotation
		AAIEnemy* const PEnemy = World->SpawnActor<AAIEnemy>(Enemy,Location,Rotation,SpawnInfo); 

		//Setup the enemy
		PEnemy->Home = this;
		PEnemy->Checkpoints = CheckPointsArray;
		PEnemy->CurrentCheckpoint = 0;
	}
}

Thanks a lot

Hi there!
Try to add following:

SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;

It doesn’t work and I have check, in my Enemy class, “Try To Adjust Location,But Always Spawn”

Hmm… Add logging into BeginPlay and BeginDestroy methods of your AAIEnemy class, just to check that some actors didn’t spawn at all.
PS: option “Try To Adjust Location,But Always Spawn” is set inside your Enemy class(that works with statically added actor), but you spawn it dynamically.

Strange, my editor crash when I launch with this error

"Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.10\Engine\Source\Runtime\CoreUObject\Private\UObject\Obj.cpp] [Line: 662]
AIEnemy //Engine//Transient.Default__AI

void AAIEnemy::BeginPlay()
{
	Super::BeginPlay();

	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Begin"), 1, 1));
}

void AAIEnemy::BeginDestroy()
{
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::White, FString::Printf(TEXT("Destroy"), 1, 1));
}

You missed Super::BeginDestroy();

Ok I have no “Destroy”, only some “Begin” with 20 tests

And yes all enemy on the outiliner is spawn
Number “Begin” == Number “Deleted Actor”

Your Enemy parameter contains correct value? And what is in Actor’s constructor?

The constructor is empty:

AAIEnemy::AAIEnemy()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
}

But it is a class from ACharacter and I use a blueprint child class of my enemy class.
What do you mean “correct value” ?

Here is my AIEnemy.h if you want:

class ASpawnZombie;

UCLASS()
class TOWERDEFENSE_API AAIEnemy : public ACharacter
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AAIEnemy();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

	virtual void BeginDestroy() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

	UPROPERTY()
		ASpawnZombie* Home;

	UPROPERTY(EditAnywhere)
		TArray<FVector> Checkpoints;
	UPROPERTY()
		uint8 CurrentCheckpoint = 0;

	UFUNCTION()
		void SetUpCheckpoints(TArray<FVector> List);
	UFUNCTION()
		void NextCheckpoint();

	UFUNCTION()
		void Die();
};