# Override GetDefaultPawnClassForController\_Implementation

**URL:** <https://forums.unrealengine.com/t/override-getdefaultpawnclassforcontroller-implementation/611898>\
**Category:** Multiplayer & Networking\
**Tags:** unreal-engine, UE5-0, Multiplayer, question\
**Created:** [July 22, 2022, 4:21pm UTC](https://forums.unrealengine.com/t/override-getdefaultpawnclassforcontroller-implementation/611898 "2022-07-22T16:21:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![artem\_blanche](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@artem\_blanche](https://forums.unrealengine.com/u/artem_blanche)\
**Post date:** [July 22, 2022, 4:21pm UTC](https://forums.unrealengine.com/t/override-getdefaultpawnclassforcontroller-implementation/611898/1 "2022-07-22T16:21:12Z")

</div>

Hey there,

I am working in UE5 and following a tutorial to [spawn different pawns for players in multiplayer](https://unrealcommunity.wiki/spawn-different-pawns-for-players-in-multiplayer-ravgudcc)

The suggestion is to override the `GetDefaultPawnClassForController_Implementation` function belonging to the `GameModeBase`. However I noticed that the function is not virtual in the source code:

```auto
/** Returns default pawn class for given controller */
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category=Classes)
UClass* GetDefaultPawnClassForController(AController* InController);

```

I tried to override anyway but my override does not get called. After placing breakpoints the debugger stops inside the original implementation but not in my override.

My code looks like this

ATP\_MLFGameModeBase.h

```auto
UCLASS()
class TP_MLF_API ATP_MLFGameModeBase : public AGameMode
{
	GENERATED_UCLASS_BODY()

public:

	UClass* GetDefaultPawnClassForController_Implementation(AController* InController) override;

private:
};

```

ATP\_MLFGameModeBase.cpp

```auto
ATP_MLFGameModeBase::ATP_MLFGameModeBase(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	/* Use our custom Player-Controller Class */
	PlayerControllerClass = AMyPlayerController::StaticClass();	
}

UClass* ATP_MLFGameModeBase::GetDefaultPawnClassForController_Implementation(AController* InController)
 {
	/* Override Functionality to get Pawn from PlayerController */
	AMyPlayerController* MyController = Cast<AMyPlayerController>(InController);

	if (MyController)
	{
		UE_LOG(LogTemp, Log, TEXT("inside returning MyController"));
		return MyController->GetPlayerPawnClass();
	}

	/* If we don't get the right Controller, use the Default Pawn */
	return DefaultPawnClass;
}

```

I am wondering whether `GetDefaultPawnClassForController` can still be overridden or whether this has changed and I should explore other avenues for setting the pawn?

---

<div class="post-metadata">

**Author:** ![Anoberia](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/anoberia/32/590142_2.png) [@Anoberia](https://forums.unrealengine.com/u/Anoberia)\
**Post date:** [May 7, 2023, 11:45am UTC](https://forums.unrealengine.com/t/override-getdefaultpawnclassforcontroller-implementation/611898/2 "2023-05-07T11:45:24Z")

</div>

Did you find a solution? I need to override this function. 😕

---

<div class="post-metadata">

**Author:** ![Muffiuz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Muffiuz](https://forums.unrealengine.com/u/Muffiuz)\
**Post date:** [May 22, 2023, 7:16am UTC](https://forums.unrealengine.com/t/override-getdefaultpawnclassforcontroller-implementation/611898/3 "2023-05-22T07:16:18Z")

</div>

I’m also looking at this. Does anyone know that the \*\_Implementation postfix to methods mean?

---

<div class="post-metadata">

**Author:** ![Scoly1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Scoly1](https://forums.unrealengine.com/u/Scoly1)\
**Post date:** [May 23, 2023, 5:46pm UTC](https://forums.unrealengine.com/t/override-getdefaultpawnclassforcontroller-implementation/611898/4 "2023-05-23T17:46:22Z")

</div>

You can override this function like this:

In the header:

```auto
virtual UClass* GetDefaultPawnClassForController_Implementation(AController* InController) override;

```

In the cpp:

```auto
UClass* AMyGameMode::GetDefaultPawnClassForController_Implementation(AController* InController)
{
	/* Override Functionality to get Pawn from PlayerController */
	AMyPlayerController* MyController = Cast<AMyPlayerController>(InController);
	if (IsValid(MyController))
	{
		return MyController->GetPlayerPawnClass();
	}
	/* If we don't get the right Controller, use the Default Pawn */
	return DefaultPawnClass;
}

```
