When the game starts, I want to spawn the player with a specific location and rotation - this must be set in code. I have deleted my default PlayerStart and I’ve tried overriding the game mode’s ChoosePlayerStart_Implementation by spawning a new PlayerStart and returning it, but this results in the player being invisible, not controllable… just completely broken. I don’t particularly need a PlayerStart, I just want to spawn the player at a specific loc/rot, but it looks like using a PlayerStart is the only way.
AActor* AMyGameGameMode::ChoosePlayerStart_Implementation(AController* Player)
{
FActorSpawnParameters SpawnInfo;
return GetWorld()->SpawnActor<APlayerStart>(FVector(0, 0, 150), FRotator(0, 45, 0), SpawnInfo);
}
I also tried having a PlayerStart present and teleporting it to the correct position each time a player spawns;
UWorld* World = GetWorld();
for (TActorIterator<APlayerStart> It(World); It; ++It)
{
APlayerStart* PlayerStart = *It;
PlayerStart->SetActorLocationAndRotation(FVector(0, 0, 150), FRotator(0, 0, 0));
return PlayerStart;
}
More problems as usual and expected, this time the thing won’t move to the location and rotation I specify.
And finally I tried spawning directly - yet again, something so simple refuses to work.
return SpawnDefaultPawnAtTransform(Player, FTransform(FRotator(0, 45, 0), FVector(0, 50, 100), FVector::OneVector));