Spawn Different Pawns For Players in Multiplayer
This wiki article was written by TheJamsh.
Overview
Step 1: Custom Game Mode
UCLASS()
class MYGAME_API AMyGameMode : public AGameMode
{
GENERATED_UCLASS_BODY()
/* Override To Read In Pawn From Custom Controller */
UClass* GetDefaultPawnClassForController(AController* InController) override;
};AMyGameMode::AMyGameMode(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
/* Use our custom Player-Controller Class */
PlayerControllerClass = AMyPlayerController::StaticClass();
}
UClass* AMyGameMode::GetDefaultPawnClassForController(AController* InController)
{
/* Override Functionality to get Pawn from PlayerController */
AMyPlayerController* MyController = Cast<AMyPlayerController>(InController);
if (MyController)
{
return MyController->GetPlayerPawnClass();
}
/* If we don't get the right Controller, use the Default Pawn */
return DefaultPawnClass;
}Step 2: Custom Player Controller
Client/Server Functions
Text File Implementation
Assertion
Final Word
Last updated
Was this helpful?