AGameModeBase::InitStartSpot
#include "GameFramework/GameModeBase.h"
Access: public
Specifiers: UFUNCTIONBlueprintNativeEvent
Description
Called from RestartPlayerAtPlayerStart just before a pawn is spawned, allowing the game mode to initialize or claim the start spot. The default implementation saves the start spot reference on the PlayerState.
Caveats & Gotchas
- • The base implementation stores StartSpot as the controller's StartSpot TWeakObjectPtr on the PlayerState, which FindPlayerStart later consults via ShouldSpawnAtStartSpot. If you override without calling Super, saved spawn points stop working for returning players.
- • This is an engine-internal hook; most games do not need to override it. Override FindPlayerStart or ChoosePlayerStart to control spawn selection instead.
- • Called server-side only inside RestartPlayerAtPlayerStart — it will not fire if you spawn pawns by other means (e.g., directly calling SpawnActor).
Signature
ENGINE_API void InitStartSpot(AActor* StartSpot, AController* NewPlayer); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| StartSpot | AActor* | The actor used as the spawn location. | — |
| NewPlayer | AController* | The controller for the player being spawned. | — |
Return Type
void Example
Mark a start spot as occupied C++
void AMyGameMode::InitStartSpot_Implementation(AActor* StartSpot, AController* NewPlayer)
{
Super::InitStartSpot_Implementation(StartSpot, NewPlayer);
// Mark the PlayerStart so ChoosePlayerStart can skip occupied ones
if (APlayerStart* PS = Cast<APlayerStart>(StartSpot))
{
PS->bTaken = true; // assuming you've added this custom property
}
} Tags
Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?