How can I get GetSpectatorPawn() to work?
I have a problem with GetSpectatorPawn(). I've created a camera like in Strategy Game Sample, but it doesn't work as expected. I belived it's caused by the problem in movement component's TickComponent() function. I obtain player pawn like in Strategy Game Sample:
But PlayerPawn is always NULL (Propably because PlayerController->GetSpectatorPawn() returns NULL). How to make it work? :D
I had the same issue, but this forum thread cleared it up for me.
In short, you can fix the problem by overriding the Reset function:
I'm still not clear on how this works in the strategy game sample, since it doesn't do this, but this fix worked for me.
Just to clarify Strategy Game Sample. It works without putting player in Playing state, because they have AStrategyGameMode::RestartPlayer override, which doesn't call Super::RestartPlayer, and in turn AGameModeBase::RestartPlayer calls AGameModeBase::RestartPlayerAtPlayerStart and there is a logic which spawns default pawn, which happens if you don't override RestartPlayer or do call Super::RestartPlayer, but doesn't happend in StrategyGameMode.
I think it's rather inconsistant example, because their PlayerState is always in bIsSpectator = false, while controller runs around rampaging with spectatorpawn :-).
Follow this question
Once you sign in you will be able to subscribe for any updates here