AGameModeBase::ChoosePlayerStart
#include "GameFramework/GameModeBase.h"
Access: public
Specifiers: virtualUFUNCTIONBlueprintNativeEvent
Description
Selects the best unoccupied PlayerStart actor for a given player. Override this to implement custom spawn selection logic such as team-based starts, furthest-enemy spawning, or checkpoint restarts.
Caveats & Gotchas
- • The default implementation picks a random unoccupied PlayerStart. If all PlayerStarts are occupied, it will still return one — your override must handle overflow gracefully.
- • This is called by FindPlayerStart when no IncomingName tag is matched. If you want to control spawning by tag, override FindPlayerStart instead.
- • Returning null from your override will cause a spawn failure; RestartPlayer will call FailedToRestartPlayer in that case — make sure to always return a valid actor or fall back to Super.
Signature
ENGINE_API AActor* ChoosePlayerStart(AController* Player); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Player | AController* | The controller for the player who needs a spawn location. | — |
Return Type
AActor* Example
Team-based spawn selection C++
AActor* AMyGameMode::ChoosePlayerStart_Implementation(AController* Player)
{
AMyPlayerState* PS = Player ? Cast<AMyPlayerState>(Player->PlayerState) : nullptr;
if (!PS)
{
return Super::ChoosePlayerStart_Implementation(Player);
}
// Find all PlayerStarts tagged with the player's team
TArray<AActor*> TeamStarts;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), APlayerStart::StaticClass(), TeamStarts);
for (AActor* Start : TeamStarts)
{
if (Start->Tags.Contains(PS->TeamTag))
{
return Start;
}
}
return Super::ChoosePlayerStart_Implementation(Player);
} Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?