Spectator camera not setup like current view target

Description: In multiplayer (with dedicated server) game, spectator camera not setup like current view target when player controller got to spectating state.

Steps for reproduce: I’ve prepared simple test “Third Person” project to illustrate this issue. Please download project by link below and run with “Run dedicated server” checkbox enabled, after that walk around on level, change camera view by mouse and press “1” on keyboard. You should see that spectator camera not setup as expected, but setup player controller camera.

Interesting method is “SwitchToSpectator” in character class.

Notes: I assume that this issue in SetPawn method, because this method called when pawn replicated from the server to client and after that setup current view target to current player controller (because this pawn will be NULL) in methods AutoManageActiveCameraTarget

Sample project link: project

Hey asherstnev,

What are your expected results with this setup? What are you trying to achieve overall?

Hey Sean,

The expected result should be set active camera/location/rotation from spectator and not from player controller. Also switching(pawn → spectator) behavior is different when run game with/without dedicated server option enabled

I’m using the next dirty fix in SetPawn because in this method the first condition set up active camera target to player controller and not to spectator

void ASPlayerController::SetPawn(APawn* InPawn)
{
	if (InPawn == nullptr && GetStateName() != NAME_Spectating)
	{
		const FVector NewLocation = (PlayerCameraManager != nullptr) ? PlayerCameraManager->GetCameraLocation() : GetSpawnLocation();
		SetSpawnLocation(NewLocation);

		if (bAutoManageActiveCameraTarget)
		{
			AutoManageActiveCameraTarget(this);
		}
	}

	AController::SetPawn(InPawn);

	if (GetPawn() && bCinematicMode && bHidePawnInCinematicMode)
	{
		GetPawn()->SetActorHiddenInGame(true);
	}
}

Thanks for the clarification, I’ve reproduced your issue and entered a bug report, which you can track using the link below:

Thank you for your report.

Have a great day