Possession not working

Hi Ensaides,

It maybe related to the Controller current state,because Controller current state is a not replicated value, then may keep the client in other state. So, you can try let all clients call PC->ChangeState(NAME_Playing); after you Possess the Pawn on server side, for example:

// in your game mode code
Itr->Possess(Cast<APawn>(NewHumanPawn));
// add this line
Itr->ClientChangeState();

then in ACustomPlayerController.h add :

UFUNCTION(reliable, client)
void ClientChangeState();

and in ACustomPlayerController.cpp add :

void ACustomPlayerController::ClientChangeState_Implementation()
{
       this->ChangeState(NAME_Playing);
}

Just give a clue, not sure it work or not, beside, Unreal already have a awesome Gameplay framework to organize the game mode, pawn, controller this kind of stuff, you can try to read ShooterGame and UE4 source code, and draw some code maps, it works for me :slight_smile:

when i try to possess a pawn that i spawned in my custom game mode, it only works on the listen server and on none of the clients

the clients cameras move over to the spawn but i cant move the camera or the pawn. on the listen server it replicates correctly to the other clients and the pawn is movable

heres the function that’s called that spawns the pawns and possess them

void ACustomGameMode::StartRound()
{
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("ROUND STARTING"));

	TObjectIterator<ACustomPlayerController> Itr;

	for (Itr; Itr; ++Itr)
	{

		ACustomPlayerState* PlayerState = Cast<ACustomPlayerState>(Itr->PlayerState);
		APawn* OldPawn = Itr->GetPawn();

		switch (PlayerState->GetJobChoice())
		{
		default:
		{

					PlayerState->SetIsPlaying(true);

					GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("CASE DEFAULT"));

					if (OldPawn) { OldPawn->Destroy(); }

					FActorSpawnParameters SpawnParams;
					SpawnParams.Owner = *Itr;
					SpawnParams.bNoCollisionFail = true;
					SpawnParams.bNoFail = true;

				        FVector const SpawnLocation = FVector(0, 0, 512);
				        FRotator const SpawnRotation = FRotator(0, 0, 0);

					UWorld* const World = GetWorld();

					AActor* const NewHumanPawn = World->SpawnActor(DefaultHumanClass, &SpawnLocation, &SpawnRotation, SpawnParams);

					Itr->Possess(Cast<APawn>(NewHumanPawn));
				   break;
		}
		case 2:
			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("CASE 2"));
			break;
		}
	}
}

that didnt work :frowning:

Have you tried:

Itr->GetPawn()->Restart();

As stated here Posses Pawn