GameKit / GKMatchRequest: 超时或强制启动?

huangapple go评论69阅读模式
英文:

GameKit / GKMatchRequest: timeout or forced start?

问题

我正在使用GKMatchmakerViewController来使用户自动与其他玩家匹配我的多人游戏:

if let matchmakerViewController = GKMatchmakerViewController(matchRequest: request) {
    matchmakerViewController.matchmakerDelegate = self
    
    let rootViewController = UIApplication.shared.windows.first!.rootViewController
    rootViewController?.present(matchmakerViewController, animated: true)
}

如果没有其他玩家可用,这种匹配方法似乎需要等待大约10分钟。没有理智的玩家会等那么长时间来匹配。

因此,我希望能够设置一个超时,以便在n秒后,即使没有填满所有插槽,匹配也会开始。然后我可以生成机器人或AI玩家。

使用GameKit是否不支持这个功能?

我尝试使用matchmakerViewController.canStartWithMinimumPlayers = true,以便即使没有填满所有插槽,也可以开始匹配,但玩家仍然被迫等待,直到连接到最低数量的玩家(最多10分钟)。

我想设置一个超时(例如30-60秒)。如果没有玩家,GKMatchmakerViewController会失败,或者返回比请求的玩家数量更少。

或者,我想实现一个"强制开始",并告诉GKMatchmakerViewController不再等待。

苹果没有考虑到这一点吗,还是我遗漏了什么?

英文:

I am using GKMatchmakerViewController to have the user auto match with players for my multiplayer game:

        if let matchmakerViewController = GKMatchmakerViewController(matchRequest: request) {
            matchmakerViewController.matchmakerDelegate = self
            
            let rootViewController = UIApplication.shared.windows.first!.rootViewController
            rootViewController?.present(matchmakerViewController, animated: true)
        }

This method of finding a match seems to wait for about 10 minutes if there are no players available. No sane player is going to wait that long for matches.

Therefore I would like to be able to set a timeout so that after n amount of seconds, the match starts anyway even though not all of the slots have been filled. I can then spawn bots or AI players.

Is this not possible with GameKit?

I tried using matchmakerViewController.canStartWithMinimumPlayers = true so it's possible to have the match start even when not all slots have been filled, but the player is then still forced to wait until the minimum amount of players are connected (still max 10 minutes).

I would like to set a timeout (eg. 30-60 seconds). The GKMatchmakerViewController would then fail if there are 0 players, or return with less players than requested.

Alternatively I would like to implement a "forced start", and tell the GKMatchmakerViewController to no longer wait.

Didn't Apple think of this or am I missing something?

答案1

得分: 0

无法在使用GKMatchmakerViewController时强制开始一场没有匹配的比赛。

作为替代方案,请使用GKMatchmaker。可以使用GKMatchmaker.shared().cancel()来取消(例如,在30秒后),然后游戏逻辑可以简单地开始一场没有玩家并添加机器人的游戏。

英文:

It is impossible to force start a match with 0 matches when using GKMatchmakerViewController.

As an alternative, use GKMatchmaker. This can be canceled with GKMatchmaker.shared().cancel() (eg. after 30 seconds) and then the game logic can simply start a game with 0 players and add bots.

huangapple
  • 本文由 发表于 2023年2月24日 14:55:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/75553417.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定