I want the player to choose between a male and female character but I can’t figure out how to change the DefaultPawn at runtime. I have made BP childs of my C++ character with different meshes but the same properties. So can anyone help me with this,.
The game mode decides what the default pawn is. In the world settings of the map in question you can specify your own game mode, and that mode can set the default pawn.
You can also specify your game mode in the project settings, then it applys to all maps unless overridden.
Thanks for the answer but I already now this wait I wanted to know was how to change between two different Pawns at runtime.
Like you start the game you get the option to choose your character and the character you choose is the one spawned. Can you help me with this?
If the properties are the same, couldn’t you just change the mesh using the Set Skeletal Mesh function, so basically only exchanging the mesh component
When spawning players, game mode calls RestartPlayer which calls SpawnDefaultPawnFor which calls GetDefaultPawnClassForController :
/** Returns default pawn class for given controller */
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category=Classes)
UClass* GetDefaultPawnClassForController(AController* InController);
As a BlueprintNativeEvent, you can override this in c++ subclasses as well as blueprint subclasses.