GetWorld()->SpawnActor< APawn>(ToSpawn) returns a nullptr

I am working through one of the Udemy courses and am getting results inconsistent with what is being presented. I have copied the code directly from the instructor in an effort to resolve this problem, so presumably this all should be working. I am trying to place pawns in the world at runtime. This is working perfectly fine with regular actors (the PlaceActor() function works) but for some reason when I try the same function with a Pawn, I get a nullptr. Specifically, even when ToSpawn is NOT a nullptr and is populated with expected values, GetWorld()->SpawnActor< APawn>(ToSpawn) returns a nullptr. I can’t tell if this is due to updates to the engine or if some unexpected value is being set erroneously.

void ATile::PlaceActor(TSubclassOf<AActor> ToSpawn, const FSpawnPosition SpawnPosition)
{
	AActor* Spawned = GetWorld()->SpawnActor<AActor>(ToSpawn);
	Spawned->SetActorRelativeLocation(SpawnPosition.Location);
	Spawned->AttachToActor(this, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false));
	Spawned->SetActorRotation(FRotator(0, SpawnPosition.Rotation, 0));
	Spawned->SetActorScale3D(FVector(SpawnPosition.Scale));
}

void ATile::PlaceAIPawn(TSubclassOf<APawn> ToSpawn, const FSpawnPosition SpawnPosition)
{
	
	APawn* Spawned = GetWorld()->SpawnActor<APawn>(ToSpawn);
	Spawned->SetActorRelativeLocation(SpawnPosition.Location);
	Spawned->AttachToActor(this, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false));
	Spawned->SetActorRotation(FRotator(0, SpawnPosition.Rotation, 0));
	Spawned->SpawnDefaultController();
	Spawned->Tags.Add(FName("Enemy"));
}

If all the values are correctly set what I can recomend you to do is to place a breakpoint right after the spawnActor function call and look into the output log when the break point triggers, you should get more information for the reason of the actor failing to spawn. My first guess is that the actor is failing to spawn because of its collisions.
Other way to check this is simply commenting everything after the spawn function call inside your placeAIPawn function, so when you call it it wont crash and youll be able to look into the log inside the editor (Window->DeveloperTools->OutputLog).

You are correct about the collisions, I was getting a “SpawnActor failed because of collision at the spawn location”. I managed to use the following code to get it working, which both forces it to spawn and spawns it above the ground (the pawns were previously inside the ground):

FVector Location(0.0f, 0.0f, 89.f); // Drags pawn above the floor
FRotator Rotation(0.0f, 0.0f, 0.0f);	
FActorSpawnParameters SpawnInfo;
SpawnInfo.SpawnCollisionHandlingOverride = SpawnActorCollisionHandlingMethod::AlwaysSpawn;
APawn* Spawned = GetWorld()->SpawnActor<APawn>(ToSpawn, Location, Rotation, SpawnInfo);