Spawning, and then possessing a character in C++

I’ve created a C++ project based off on the Third person template.
Now, whenever I try to play in multiplayer (in the editor), my first player possess the third person character present in the level.
All the other ones appear as grey spheres, and don’t have any player characters attached.

I’m trying to figure out why, and how to actually solve it.

I’m thinking that I should probably delete the player character that I already have in the game, and spawn a character for every player that connects.

How would I go about doing it? This is a very general question, so very general answers are more than welcome.
Is my approach correct? If so, how to actually implement it? If not, what else can I do?
If you could give me some links to videos or tutorials, that would be very appreciated.
Or perhaps, a few pointers on where to look it up in the Survival Game project.

Thanks in advance. Any advice will be helpful.

Hi Lord,

I believe the reason your other players are spawning into grey spheres is that they are set to have ASpectatorPawn as default pawns. One easy way to test this would be to copy the character which is placed in the level in the third person template. Make a copy for each of the clients you want to load in. In the properties window for each of those pawns, under the “Pawn” tab there is an option to auto-possess by player. The existing character is probably set to player 0. If you have two more clients you want to load in, then you will have to set your new copied characters to player 1 and player 2 respectively. Doing this, you are forcing the clients to possess the ThirdPersonCharacter rather than spawning their own default.

They should load in and possess those pawns.

The other option you mentioned is also pretty easy, and is probably the better way to move forward. In order to have players spawn their own pawn and possess it, go to the Blueprints tab above the PIE viewport, World Override, and set the default pawn under ‘Game Mode Classes’ to the same character which is existing in the level.

Edit: Realized that since you’re using C++ there may not be a game mode blueprint for that template. If you are using a custom game mode, or if the ThirdPersonGameMode is defined in C++. You can set the default pawn class in the game mode constructor.

AMyGameMode::AMyGameMode(const FObjectInitializer& IO)
     : Super(IO)
     DefaultPawnClass = AMyDefaultPawn::StaticClass();

I worked, but my character is actually a blueprint, so I had to create a reference to the blueprint from code.
The general idea worked, though.

Awesome! Just remember that if you ever rename or move that character blueprint you’ll have to update it in code also. If you’re using the actual path that is. ;]