How-To: Declared Teams & Colors
Goal: declare named teams on the Game State, auto-assign players to them, and drive per-team colors - the full PvP/faction setup beyond raw tags.
1. Make a display asset per team
Content Browser -> right-click -> Data Asset -> CrimsonTeamDisplayAsset (one per team). Fill ColorParameters (e.g. TeamColor), ScalarParameters, TextureParameters, and TeamShortName. These names match the parameters on your team materials.
Images/CrimsonTeams/howto-display-asset.png2. 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 key | value |
|---|---|
Team.Red | DA_Team_Red |
Team.Blue | DA_Team_Blue |
UCrimsonTeamCreationComponent::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.
void UMyTeamCreation::ServerChooseTeamForPlayer_Implementation(APlayerState* PS){if (UCrimsonTeamAgentComponent* Team = PS->FindComponentByClass<UCrimsonTeamAgentComponent>()){Team->JoinTeam(FGameplayTag::RequestGameplayTag(FName("Team.Red"))); // your choice}}
4. Apply the colors
Resolve an agent's display asset and apply it to materials / Niagara, or let the async observer keep UI in sync.
// Push team colors onto every mesh / Niagara on an actor:if (UCrimsonTeamDisplayAsset* DA = UCrimsonTeamStatics::GetTeamDisplayAssetForAgent(Pawn)){DA->ApplyToActor(Pawn, /*bIncludeChildActors*/ true);}// Safe per-parameter reads with a fallback:const FLinearColor C = UCrimsonTeamStatics::GetTeamColorWithFallback(DA, TEXT("TeamColor"), FLinearColor::White);
See also
- Concept: Team Registration & Info Actors - what the creation component spawns and how registry works
- API Reference - display asset, creation component, info actors