Spawned BP actor does not show up


i’ve made a test BP of a building that spawns aliens in 10 second intervals. The problem is the AI of the alien instance (BP) does not work. So I thought i’ll do it in code (i’d do it in the future). The problem here is that, when i call world spawn, i do not see the spawned object and in the editor there is a deleted actor. I think the object just got garbage collected. Can somebody please give me directions on what am i doing wrong? Because i searched for answers and everything that i found does not work.

To the test the object i only drag and drop it from content browser to scene and then hit run. I am using UE 4.8.3 because UE 4.9.0 was just crashing and crashing :frowning: .


code below

#pragma once

#include "Engine/StaticMeshActor.h"
#include "EnemyHiveCpp.generated.h"

UCLASS(Config = Game, BlueprintType, Blueprintable)
class TESTCPP48_API AEnemyHiveCpp : public AStaticMeshActor

	FDateTime timeStart;
	UClass* classToSpawn;


	AActor * spawnedPawn;


	virtual void TickActor(float DeltaTime, enum ELevelTick TickType, FActorTickFunction & ThisTickFunction) override;

#include “TestCpp48.h”
#include “EnemyHiveCpp.h”

	PrimaryActorTick.bCanEverTick = true;
	ConstructorHelpers::FObjectFinder<UBlueprint> enemyPawnToSpawn(TEXT("Blueprint'/Game/MyEnemyPawn.MyEnemyPawn'"));
	if (enemyPawnToSpawn.Object != nullptr)
		classToSpawn = (UClass*)enemyPawnToSpawn.Object->GeneratedClass;
		UE_LOG(LogTemp, Warning, TEXT("DID NOT FIND OBJECT"));

	spawnedPawn = nullptr;

void AEnemyHiveCpp::TickActor(float DeltaTime, enum ELevelTick TickType, FActorTickFunction & ThisTickFunction)

	FDateTime now = FDateTime::Now();
	FTimespan d = now - timeStart;
	int32 sec = d.GetSeconds(); 
	if (sec > 10)
		FVector location = GetActorLocation();
		FActorSpawnParameters fasp;

		if (classToSpawn != nullptr)
			FVector location;
			FActorSpawnParameters fasp;
			fasp.Owner = this;
			fasp.Instigator = Instigator;
			fasp.bDeferConstruction = false;

			timeStart = now;

			if (spawnedPawn == nullptr)
				spawnedPawn = GetWorld()->SpawnActor(classToSpawn, &location, &FRotator::ZeroRotator, fasp);

				UE_LOG(LogTemp, Warning, TEXT("SPAWNED %s"), *(spawnedPawn->GetName()));

So I found the problem; the spawn position was not initialized to 0,0,0. In 4.9.1 i got a warning that the object is out of world boundaries, in 4.8.3 (that i originaly used) i got no warning.