Multiplayer change tag of the character controller at start

I am making a multiplayer game, and i have set 2 different starting points for the teams i have set different tags on the starting points and i have set a tag on my character blueprint, the problem that i am facing is that both of the characters are spawning at the same starting point, which makes sense since they have the tag of TeamA,

How i can change one of the character to tag TeamB so will spawn on the correct starting point. I am using C++.

The way we did it, is that we overrode two AGameMode methods:

void AGameMode::PostLogin(APlayerController* NewPlayer)
{
    // In this function, we assign a new player to a team.
    // At this point, a player has not spawned yet.
}

That function basically assigns a new player a team, immediatly after he succesfully logged into our game.
Then, we override the other function:

AActor* AGameMode::ChoosePlayerStart(AController* Player)
{
    // Find a suitable APlayerStart for the player according to his or her team.
}

The last function will try to find a correct playerstart, based on the player’s team. The playerstart returned by this function will be used by AGameMode to spawn the player. I hope this helps.

Thank you for your reply i have already overrided ChoosePlayerStart and setTeam functions and i have implemented the tag check between starting points and characters. And works.

What i want is since i am using the editor currently to test the multiplayer and i haven’t implemented buttons yet to choose teams or any other login functionality, I want to change in code any one of the two characters tag and go to the second starting point.

I am not home but if i try the following i think will work.Since will change tag only at the client that is the server correct?

void AGameMode::PostLogin(APlayerController* NewPlayer) {
If (Role == Role_Authority){
this.tags[0] = “TeamB”;
}
}

Is there any other way to check how many players are and at only the first or second change the tag?

Just as a reminder, AGameMode only exists on the server so there’s no need to check for role authority there.

As for the team-assigning, we don’t use tags. Instead, we put the team as a replicated property in the player’s APlayerState. We then simply created a method AGameState::GetPlayers(const ETeam::Type Team) to get an array of players of a certain team, and thus also the amount of players in that team. Remember, AGameMode owns a AGameState, and that game state has an APlayerState for each player. Inside PostLogin(APlayerController* NewPlayer), you can directly get the correct APlayerState, as the state will be stored as a property inside that APlayerController.

I fixed it, the only difference is that i used the ChoosePlayerStart and i change the team number of the player to a string and check if matches with the starting points Tag ( 0 and 1). The other way i thought was to create a class that will replace the starting point and will have a property number to compare.