I am trying to understand how/when the ChoosePlayerStart method of GameMode get’s called. From using breakpoints in debugging I’ve found that it definitely gets invoked before GameMode’s BeginPlay which makes sense if BeginPlay is the last thing that will get called.
I’ve thought about tagging my players as player1 and player2 and also giving the PlayerStart object’s tags like this, but I’m not sure when to do this to ensure that the ChoosePlayerStart hasn’t been called yet, or else it won’t really matter.
If you can explain when this gets called or point me towards any documentation that would be phenomenal!
ChoosePlayerStart is called in AGmeModeBase::FindPlayerStart_Implementation which in turn is called in AGameModeBase::InitNewPlayer.
This is all I know so far, but I’m working out how to override this functionality myself at the moment, so I’ll be sure to add any more info I find out about it.
Edit: So, AGameModeBase::Login calls InitNewPlayer which in turn is called by UWorld::SpawnPlayActor which is called by ULocalPlayer::SpawnPlayActor.
I set a Breakpoint and followed the call stack back to source this info.
SpawnPlayActor appears to be called from else
UGameInstance::StartPlayInEditorGameInstance and UGameInstance::CreateLocalPlayer
both call SpawnPlayActor when running in the editor.
Hey I can’t say for sure who calls ChoosePlayerStart and when, I do have my player start working out nicely now, no weird conflicts or nullpointers in multiplayer. If you’re having issues getting your player character’s to spawn in multiplayer, I can at least try and take a look at what you are doing, and review what changes I had to make.
I’m looking to re-jig the spawn system to suit my game. I wanted to replace the APlayerStart with a custom actor of my own and call a function on it. Trouble is that that this meant digging into the engine a bit to form an understanding. ^^’
I’ve compiled a crude list of function calls leading to the ChoosePlayerStart call in an answer for future reference.
Well I do know that ChoosePlayerStart_Implementation will just return an AActor, so if you are overriding that it should be pretty easy. I went ahead and marked your answer as correct because I think it gives a good overview of the call hierarchy, and hopefully that’s useful to someone down the line.