使用 Blueprint 集成
Use the Matchmaker Blueprint API to add matchmaking functionality to your Unreal Engine game without writing code.
阅读时间7 分钟最后更新于 4 天前
以下部分展示如何使用 Unreal Engine 中的 Blueprint 与 Matchmaker SDK 集成。 您可以在 Unity Gaming Services SDK 中进行交互的两个 Matchmaker 接口是:
安装 Matchmaker SDK 插件
继续下一步前,请将MatchmakerSDKMatchmakerServerMatchmakerClientYourProjectName.Build.csPublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });PublicDependencyModuleNames.AddRange(new string[] { "MatchmakerClient", "MatchmakerServer" });PublicDependencyModuleNames.AddRange(new string[] { "Json", "JsonUtilities" });
Matchmaker Client Blueprint API
Matchmaker Client Subsystem 控制关于匹配和寻找匹配玩家的客户端部分。此部分包括创建、删除和轮询匹配工单。 使用UMatchmakerClientBlueprintApiCreateTicket
要使用CreateTicketTicketIdFString


ResponseSplit Struct PinCreateTicketResponseDeleteTicket
使用DeleteTicket
ResponseSplit Struct PinDeleteTicketResponseGetTicketStatus
使用GetTicketStatusTicketIdDeleteTicket
ResponseSplit Struct PinGetTicketStatusResponse]Set Timer by EventClear and Invalidate Timer by Handle
GetTicketStatus
Matchmaker Server Blueprint API
Matchmaker Server Subsystem 控制关于匹配的服务器部分。此部分包括创建、审批、删除和更新回填工单。 您可以使用UMatchmakerServerBlueprintApiCreateBackfillTicket
当一名(或多名)玩家离开完整匹配,因此服务器需要填补空缺时,您需要创建新的回填工单。可以使用 Create Backfill Ticket Blueprint 为服务器创建新的回填工单。


ResponseSplit Struct PinCreateBackfillTicketResponseApproveBackfillTicket
使用 Approve Backfill Ticket Blueprint 定期审批您的回填工单,让新玩家进入服务器。 建议审批回填工单的速度不要超过每秒一次。如果 20 秒内未审批工单,Matchmaker Service 就会将工单删除。
ResponseSplit Struct PinApproveBackfillTicketResponseUpdateBackfillTicketBackfillTicketUpdateBackfillTicket
每当发生以下情况时,请更新回填工单:- 一名玩家离开服务器
- 一名玩家从匹配逻辑之外加入服务器

ResponseSplit Struct PinUpdateBackfillTicketResponseApproveBackfillTicket
Unity 建议先调用
ApproveBackfillTicketApproveBackfillTicketBackfillTicketUpdateBackfillTicketDeleteBackfillTicket
当匹配人数已满之后,服务器不再需要接受新玩家时,您可以删除回填工单。匹配结束后,也应该执行此操作。 可以使用 Delete Backfill Ticket Blueprint 停止服务器上的回填。
ResponseSplit Struct PinDeleteBackfillTicketResponseBlueprint 实用函数
由于 Blueprint 的限制,JSON 数据类型(例如FJsonObjectFJsonValue- 作为
MatchmakerServerBlueprintUtil的一部分MatchmakerServer - 作为
MatchmakerClientBlueprintUtil的一部分MatchmakerClient
MatchmakerClientMatchmakerServerMatchmakerCoreMatchmakerClient
玩家自定义数据
在MatchmakerClientMatchmakerClientBlueprintUtil您可以使用此 Blueprint 向玩家的 CustomData 对象添加字符串数据字段。 如果成功设置数据,返回 true;否则,返回 false。PlayerCustomDataAddStringData(FMatchmakerPlayer& Player, FString Key, FString Value)
您可以使用此 Blueprint 向玩家的 CustomData 对象添加数字数据字段。 如果成功设置数据,返回 true;否则,返回 false。PlayerCustomDataAddNumberData(FMatchmakerPlayer& Player, FString Key, float Value)
您可以使用此 Blueprint 从玩家的 CustomData 对象移除数据字段。 如果玩家的 CustomData 包含PlayerCustomDataRemoveData(FMatchmakerPlayer& Player, FString Key)
KeyKey属性
在MatchmakerClientMatchmakerClientBlueprintUtil可以使用此 Blueprint 向CreateTicketOptionsAddStringAttribute(FCreateTicketOptions& Options, FString Key, FString Value)
CreateTicketOptions可以使用此 Blueprint 向CreateTicketOptionsAddNumberAttribute(FCreateTicketOptions& Options, FString Key, float Value)
CreateTicketOptions可以使用此 Blueprint 从CreateTicketOptionsRemoveAttribute(FCreateTicketOptions& Options, FString Key)
CreateTicketOptionsCreateTicketOptionsMatchmakerServer
在MatchmakerServerMatchmakerServerBlueprintUtil您可以使用此 Blueprint 向CreateBackfillTicketOptionsAddStringAttribute(FCreateBackfillTicketOptions Options, FString Key, FString Value)
CreateBackfillTicketOptions此 Blueprint 用于向CreateBackfillTicketOptionsAddNumberAttribute(FCreateBackfillTicketOptions& Options, FString Key, float Value)
CreateBackfillTicketOptions可以使用此 Blueprint 从CreateBackfillTicketOptionsRemoveAttribute(FCreateBackfillTicketOptions Options, FString Key)
CreateBackfillTicketOptionsCreateBackfillTicketOptions