Hi, I am trying to spawn a BP in code and am having trouble working out what the SpawnActor() function is not accepting my parameters.
I think it probably has something to do with my not having done c++ since school and there is some obvious syntax i am doing wrong but i cant for the life of me work it out.
My BP is defined in the header as follows:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = BPClasses)
UClass* MazeTileBP;
And then i am trying to spawn my grid with the following code:
void AMazeGameMode::GenerateMaze(float tileX, float tileY)
{
FActorSpawnParameters SpawnInfo;
SpawnInfo.bNoCollisionFail = true;
SpawnInfo.Owner = this;
SpawnInfo.bDeferConstruction = false;
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("GENERATING MAZE"));
}
for (int x = 0; x < tileX; x++)
{
for (int y = 0; y < tileY; y++)
{
FVector TileSpawnLoc(x + tileX, y + tileY, 0.0f);
FRotator TileSpawnRotation(0.0f, 0.0f, 0.0f);
AStaticMeshActor* NewTile = GetWorld()->SpawnActor(MazeTileBP, TileSpawnLoc, TileSpawnRotation, SpawnInfo);
}
}
}
The line where i am calling GetWorld()->SpawnActor() at the end is telling me there is no such overload that accepts the params i have given it but they seem like correct params to me.
Any help spotting what i can’t is appreciated!
Dace