CrimsonTeams · Lesson 5 of 6

Declared Teams & Colors

Intermediate5 minMultiplayerUI

Before you start

  • Completed: Agents & Attitude
  • A Game State you can add a component to
Video coming soon

Chapters

1. A display asset per team

Content Browser → right-click → Data AssetCrimsonTeamDisplayAsset (one per team). Fill ColorParameters (e.g. TeamColor), ScalarParameters, TextureParameters, and TeamShortName. These names match the parameters on your team materials.

2. Declare the teams on the Game State

Add a Crimson Team Creation Component to your Game State and fill Teams To Create (tag → display asset). On BeginPlay (server) it spawns the replicated ACrimsonTeamPublicInfo / PrivateInfo actors and registers them with the subsystem.

Teams To Create keyvalue
Team.RedDA_Team_Red
Team.BlueDA_Team_Blue
Inject teams from a Game Feature
Mode-specific teams can be added/removed at runtime via AddTeams / RemoveTeams (call them from a Game Feature Action's activate/deactivate) — no edit to the base Game State.

3. Assign players to teams

Players are auto-assigned on join. Override ServerChooseTeamForPlayer to control how; the default picks the least-populated team.

cpp
void UMyTeamCreation::ServerChooseTeamForPlayer_Implementation(APlayerState* PS)
{
if (UCrimsonTeamAgentComponent* Team = PS->FindComponentByClass<UCrimsonTeamAgentComponent>())
{
Team->JoinTeam(/* your choice */ Tag_Team_Red);
}
}

4. Apply the colors

Resolve an agent's display asset and apply it to materials / Niagara, or let an async observer keep UI in sync.

cpp
// Push team colors onto every mesh / Niagara on an actor:
if (UCrimsonTeamDisplayAsset* DA = UCrimsonTeamStatics::GetTeamDisplayAssetForAgent(Pawn))
{
DA->ApplyToActor(Pawn, /*bIncludeChildActors*/ true);
}
// Safe per-parameter read with a fallback:
const FLinearColor C = UCrimsonTeamStatics::GetTeamColorWithFallback(DA, TEXT("TeamColor"), FLinearColor::White);
Verify
Play as 2+ players: each spawns on a team, team-colored materials apply, and the Dev Tools Teams tab lists both teams with their display assets and member counts.