Spawning enemies at different point

Hello everyone,

I am trying to get my AI to spawn at a different position each time one is spawned but I am getting a error when spawning the character. My error is error C3867: ‘AActor::GetTransform’: non-standard syntax; use ‘&’ to create a pointer to member and this is my code


void AAuroraSurvivalGamemode::OnSpawnWave(TSubclassOf<AAuroraBaseAICharacter> enemyClassToSpawn, int32 enemiesToSpawn)
{
	// Creating Spawn Params
	FActorSpawnParameters spawnParams;
	spawnParams.Instigator = Instigator;
	spawnParams.Owner = this;

	// For loop for spawning enemies
	for (int32 i = 1; i <= enemiesToSpawn; i++)
	{
		// Generate random number for spawn switching
		int32 randomNum = FMath::RandRange(0, spawnLocations.Num());

		// Recast the array to the correct object
		TArray<AAuroraAISpawnPoint*>& CastedArray = reinterpret_cast<TArray<AAuroraAISpawnPoint*>&>(spawnLocations);

		AAuroraBaseAICharacter* AiCharacter = GetWorld()->SpawnActor<AAuroraBaseAICharacter>(enemyClassToSpawn, CastedArray[randomNum]->GetTransform, spawnParams);

		// Increment enemies alive
		currentEnemiesAlive++;
	}

	// Increase the current wave count
	currentWave++;

	// Debug message on new round
	GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Green, TEXT("Current Wave: ") + FString::SanitizeFloat(currentWave));
}


My error is on the spawn character line. I am completely out of ideas on how to fix this :frowning:

Thanks :slight_smile:

GetTransform is a method, you need to call it -> add () after, so it becomes CastedArray[randomNum]->GetTransform()

It compiles now but breaks as soon as I play the game. I think it might be something with my array im using UGameplayStatics::GetAllActorsOfClass to get the spawnpoints.