文档

​
​

Development

User Acquisition

Monetization

工业

Multiplayer Services SDK

All Services

Multiplayer Services SDK

此页面不支持所选语言。
Multiplayer
​
​
Multiplayer Services SDK
  • Overview
  • Get started
  • Use multiplayer sessions
  • Manage sessions
  • Connect players through a relay
  • Networking
  • Matchmaking
    • Get started with matchmaking
    • Manage and configure matchmaking
      • Matchmaking rules
      • Matchmaking rule relaxation
      • Matchmaking with Quality of Service
      • Player segmentation
      • Matchmaker backfill
      • Matchmaking rule samples
      • Matchmaker A/B testing
    • Matchmaker troubleshooting
    • Integrations with other UGS services
    • Deploy Matchmaker configurations
  • Monitor and debug sessions
  • Tutorials
  • Reference
  1. Multiplayer Services SDK

Rules Sample

Apply example matching rules for common game scenarios like one-versus-one, team-based, and asymmetrical matches.
阅读时间5 分钟
最后更新于 16 天前

Here are some examples of rules that can be used to create different types of matches.

1v1

{ "Name": "1v1", "BackfillEnabled": false, "MatchDefinition": { "Teams": [ { "Name": "Teams", "TeamCount": { "Min": 2, "Max": 2 }, "PlayerCount": { "Min": 1, "Max": 1 } } ] }}
The following code is an example of ticket and player data.
{ "queueName": "Default", "attributes": {}, "players": [{ "id": "swsqozxo6qxm9fmm38khh3tddv35", "customData": {} }]}

QoS is equivalent for all the players in the match

{ "Name": "1v1", "MatchDefinition": { "Teams": [ { "Name": "Teams", "TeamCount": { "Min": 2, "Max": 2 }, "PlayerCount": { "Min": 1, "Max": 1 } } ], "MatchRules": [ { "Name": "QoS", "Type": "Difference", "Source": "Players.QosResults.Latency", "Reference": 20, "Not": false, "EnableRule": true } ] }, "BackfillEnabled": false}
The following code is an example of ticket and player data.
{ "queueName": "Default", "attributes": {}, "players": [{ "id": "w4505uhp7ohr27di0ob9qdncaq5b", "customData": {}, "qosResults":[ { "regionId": "61dd5b48-d24c-11ed-afa1-0242ac120002", "packetLoss": 0.8, "latency": 50 }, { "regionId": "cf32c6e1-46ff-4904-9a37-359fc66bf382", "packetLoss": 0.0, "latency": 10 } ] } ]}

5v5, Team Red vs Team Blue

The following code includes two different teams. Players must have chosen the team they want to play in.
{ "Name": "5v5 - Red vs Blue", "MatchDefinition": { "Teams": [ { "Name": "Team Red", "TeamCount": { "Min": 1, "Max": 1 }, "PlayerCount": { "Min": 5, "Max": 5 }, "TeamRules": [ { "Name": "Team Red", "Type": "Equality", "Source": "Players.CustomData.Team", "Reference": "Red", "Not": false, "EnableRule": true } ] }, { "Name": "Team Blue", "TeamCount": { "Min": 1, "Max": 1 }, "PlayerCount": { "Min": 5, "Max": 5 }, "TeamRules": [ { "Name": "Team Blue", "Type": "Equality", "Source": "Players.CustomData.Team", "Reference": "Blue", "Not": false, "EnableRule": true } ] } ], "MatchRules": [] }, "BackfillEnabled": false}
The following code is an example of compatible ticket and player data.
{ "queueName": "Default", "attributes": {}, "players": [{ "id": "e16naw0e6cgm8kw3vimtxt9qmhva", "customData": { "Team": "Blue" } } ]}

60 players

A 60-players match, similar to Battle Royal, with no teams.
The number of minimum players to start the game relaxes to 30 after the oldest ticket in the match is 15 seconds old.
Backfill is enabled, allowing players to join after the match is created.
{ "Name": "60 Players", "MatchDefinition": { "Teams": [ { "Name": "Team", "TeamCount": { "Min": 1, "Max": 1 }, "PlayerCount": { "Min": 60, "Max": 60, "Relaxations": [ { "Type": "RangeControl.ReplaceMin", "AgeType": "Oldest", "Value": 30, "AtSeconds": 15 } ] }, "TeamRules": [] } ], "MatchRules": [] }, "BackfillEnabled": true}
The following code is an example of compatible ticket and player data.
{ "queueName": "Default", "attributes": {}, "players": [{ "id": "x7e9zb9t1928r0zw8x5j1sxhowkl", "customData": {} } ]}

20 teams of 3 players

The following sample includes 20 teams of exactly 3 players. The number of minimum teams to start the game relaxes when the youngest ticket in the match is 15 seconds old. The number of players in a team is always 3.
{ "Name": "20 teams of 3 players", "MatchDefinition": { "Teams": [ { "Name": "Team", "TeamCount": { "Min": 20, "Max": 20, "Relaxations": [ { "Type": "RangeControl.ReplaceMin", "AgeType": "Youngest", "Value": 10, "AtSeconds": 15 } ] }, "PlayerCount": { "Min": 3, "Max": 3, "Relaxations": [] }, "TeamRules": [] } ], "MatchRules": [] }, "BackfillEnabled": true}
The following code is an example of compatible ticket and player data.
{ "queueName": "Default", "attributes": {}, "players": [{ "id": "91isf42z1n95lpv52upxrjc4ttvj", "customData": {} } ]}

Everyone in a team has chosen a different character

{ "Name": "20 teams of 3 players", "MatchDefinition": { "Teams": [ { "Name": "Team", "TeamCount": { "Min": 20, "Max": 20, "Relaxations": [] }, "PlayerCount": { "Min": 3, "Max": 3, "Relaxations": [] }, "TeamRules": [ { "Name": "Different characters", "Type": "Equality", "Source": "Players.CustomData.Character", "Not": true, "EnableRule": true } ] } ], "MatchRules": [] }, "BackfillEnabled": true}
The following code is an example of compatible ticket and player data.
{ "queueName": "Default", "attributes": {}, "players": [{ "id": "1v0wykm1d3edny8mcdnx53yr7wrg", "customData": { "Character":"Cloud" } } ]}

Asymmetrical 5v1 - Human vs Monster

Every player in the Human team must have the Human value to
true
.
The player in the Monster team must have the Monster value to
true
.
These rules allow players to choose more than 1 role.
{ "Name": "Asymmetrical 5v1", "MatchDefinition": { "Teams": [ { "Name": "Human", "TeamCount": { "Min": 1, "Max": 1, "Relaxations": [] }, "PlayerCount": { "Min": 5, "Max": 5, "Relaxations": [] }, "TeamRules": [ { "Name": "Human", "Type": "Equality", "Source": "Players.CustomData.Human", "Reference": "true", "Not": false, "EnableRule": true } ] }, { "Name": "Monster", "TeamCount": { "Min": 1, "Max": 1 }, "PlayerCount": { "Min": 1, "Max": 1 }, "TeamRules": [ { "Name": "Monster", "Type": "Equality", "Source": "Players.CustomData.Monster", "Reference": "true", "Not": false, "EnableRule": true } ] } ], "MatchRules": [] }, "BackfillEnabled": false}
The following code is an example of compatible ticket and player data.
{ "queueName": "Default", "attributes": {}, "players": [{ "id": "ngbbufcpbph227f42rpdv0v8zs75", "customData": { "Human": "true", "Monster": "false" } } ]}

Require some roles to be filled in the match

These rules require that the Human team contains players with the following roles:
  • 1 Medic
  • 2 Tanks
  • 2 DPS
{ "Name": "Asymmetrical 5v1", "MatchDefinition": { "Teams": [ { "Name": "Human", "TeamCount": { "Min": 1, "Max": 1, "Relaxations": [] }, "PlayerCount": { "Min": 5, "Max": 5, "Relaxations": [] }, "TeamRules": [ { "Name": "Human", "Type": "Equality", "Source": "Players.CustomData.Human", "Reference": "true", "Not": false, "EnableRule": true }, { "Name": "Medic", "Type": "GreaterThanEqual", "Source": "Players.CustomData.Medic.Sum", "Reference": 1, "Not": false, "EnableRule": true }, { "Name": "Tank", "Type": "GreaterThanEqual", "Source": "Players.CustomData.Tank.Sum", "Reference": 2, "Not": false, "EnableRule": true }, { "Name": "DPS", "Type": "GreaterThanEqual", "Source": "Players.CustomData.DPS.Sum", "Reference": 2, "Not": false, "EnableRule": true } ] }, { "Name": "Monster", "TeamCount": { "Min": 1, "Max": 1 }, "PlayerCount": { "Min": 1, "Max": 1 }, "TeamRules": [ { "Name": "Monster", "Type": "Equality", "Source": "Players.CustomData.Monster", "Reference": "true", "Not": false, "EnableRule": true } ] } ], "MatchRules": [] }, "BackfillEnabled": false}
The following code is an example of compatible ticket and player data.
{ "queueName": "Default", "attributes": {}, "players": [{ "id": "l142lvdrbuyox8lwxs5sfyt8lshv", "customData": { "Human": "true", "Monster": "false", "Medic": 1, // the role the player chose "Tank": 0, "DPS": 0 } } ]}

Lobby-like game server

These rules request a game server as soon as someone creates a ticket if no servers are running. Otherwise, backfill fills up the server that is running.
{ "Name": "City", "MatchDefinition": { "Teams": [ { "Name": "City", "TeamCount": { "Min": 1, "Max": 1, "Relaxations": [] }, "PlayerCount": { "Min": 1, "Max": 100, "Relaxations": [] }, "TeamRules": [] } ], "MatchRules": [] }, "BackfillEnabled": true}
{ "queueName": "Default", "attributes": {}, "players": [{ "id": "cb108q26yxt3lldyjfg54p8uuayk", "customData": {} } ]}

Players can choose the city they are in

Every player in a match must have the same city. If it can't find a match with that city, matchmaker requests a new allocation for that city.
{ "Name": "City", "MatchDefinition": { "Teams": [ { "Name": "City", "TeamCount": { "Min": 1, "Max": 1, "Relaxations": [] }, "PlayerCount": { "Min": 1, "Max": 100, "Relaxations": [] }, "TeamRules": [] } ], "MatchRules": [ { "Name": "City", "Type": "Equality", "Source": "Players.CustomData.City", "Not": false, "EnableRule": true } ] }, "BackfillEnabled": true}
The following code is an example of compatible ticket and player data.
{ "queueName": "Default", "attributes": {}, "players": [{ "id": "cb108q26yxt3lldyjfg54p8uuayk", "customData": { "City": "Azarel" } } ]}

Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。

  • 在本页上
    • 1v1

      • QoS is equivalent for all the players in the match

    • 5v5, Team Red vs Team Blue

    • 60 players

    • 20 teams of 3 players

      • Everyone in a team has chosen a different character

    • Asymmetrical 5v1 - Human vs Monster

      • Require some roles to be filled in the match

    • Lobby-like game server

      • Players can choose the city they are in


报告此页面的问题