Download

Current Level is nullpointer

Hey there!

I am currently trying to spawn an AActor-based actor (AChunk) in a UClass-based class (UWorldGenerator). But I ran into some problems regarding this.


chunkCords.Add(FVector2D(vectorX, vectorY));
FVector Location(0.0f, 0.0f, 0.0f);
FRotator Rotation(0.0f, 0.0f, 0.0f);
FActorSpawnParameters spawnParams;
AChunk* tmpChunk = GetWorld()->SpawnActor<class AChunk>(GetClass(), Location, Rotation, spawnParams);
					

My problem is that the level is apperently a nullpointer. Even when I try something like:



spawnParams.OverrideLevel =	GetWorld()->GetCurrentLevel();
					


the GetCurrentLevel()-function ends up having a nullpointer error as well. Can anybody help me with this?

UObject based class need to override the GetWorld() function to return a proper UWorld. By default it returns nullpointer.