Saturday, June 13, 2026
HomeiOS Developmentios - GameKit match.findMatch() doesn't add GKLocalPlayer to match

ios – GameKit match.findMatch() doesn’t add GKLocalPlayer to match

[ad_1]

I’m utilizing customized GKMatch with out the Recreation Heart interface with SwiftUI. When participant clicks button to seek out match, the next discover() perform executes:

    func request() {
        matchRequest.minPlayers = 2
        matchRequest.maxPlayers = 2
    }

    func discover() {
        if Multiplayer.shared.supervisor == nil {
            Multiplayer.shared.supervisor = MultiplayerManager()
        }
        GKLocalPlayer.native.register(Multiplayer.shared.supervisor!)
        
        Activity {
            do {
                match = attempt await matchMaker.findMatch(for: matchRequest)
                match?.delegate = Multiplayer.shared.matchDelegate
                if match != nil {
                    DispatchQueue.essential.async {
                        self.matchFound = true
                    }
                }
            }
            catch {
                fatalError()
            }
        }
    }

MultiplayerManager is of sort GKLocalPlayerListener and matchDelegate is GKMatchDelegate.

Testing with two units and clicking the button, the match is being created, however I get an error:

[Match] can’t set connecting state for gamers: … as there isn’t a inviteDelegate set but. The state would possibly instantly change to Prepared after we set the inviteDelegate later and name sendQueuedStatesAndPackets.

From what I discovered this error doesn’t forestall creating match however my essential challenge is that when taking a look at match.gamers, the native participant will not be there, so I can solely see the participant that’s linked from the opposite system. This is identical for each units, GKLocalPlayer will not be being added to the match whereas the opposite one is.

Any assist could be significantly appreciated. Thanks.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments