GKLocalPlayer

Inherits: GKPlayer < RefCounted < Object

Represents the signed-in Game Center player and exposes local-only APIs.

Description

Use GKLocalPlayer to inspect authentication flags and to fetch the local player’s friends as shown in the “Players” section of GameCenterGuide.md. Every asynchronous call mirrors Apple’s API and invokes your Callable with the requested data plus an optional error Variant (which contains a GKError on failure). Refer to Apple’s documentation at Apple’s GKLocalPlayer reference for platform-specific behavior.

Sample from the guide that fetches the local player when your scene loads:

var game_center: GameCenterManager
var local: GKLocalPlayer

func _ready() -> void:
    game_center = GameCenterManager.new()
    local = game_center.local_player
    print("ONREADY: local, is auth: %s" % local.is_authenticated)
    print("ONREADY: local, player ID: %s" % local.game_player_id)

Friends-related helpers mirror the snippets in the guide (assuming you stored the player reference in local):

# Loads the local player's friends list if access is granted.
local.load_friends(func(friends: Array[GKPlayer], error: Variant) -> void:
    if error:
        print(error)
    else:
        for friend in friends:
            print(friend.display_name)
)

# Loads players the local user can challenge.
local.load_challengeable_friends(func(friends: Array[GKPlayer], error: Variant) -> void:
    if error:
        print(error)
    else:
        for friend in friends:
            print(friend.display_name)
)

# Loads the friends or recent players list.
local.load_recent_friends(func(friends: Array[GKPlayer], error: Variant) -> void:
    if error:
        print(error)
    else:
        for friend in friends:
            print(friend.display_name)
)

Properties

bool

is_authenticated

false

bool

is_multiplayer_gaming_restricted

true

bool

is_personalized_communication_restricted

true

bool

is_underage

false

Methods

void

delete_saved_games(named: String, callback: Callable)

void

fetch_items_for_identity_verification_signature(callback: Callable)

void

fetch_saved_games(callback: Callable)

void

load_challengeable_friends(callback: Callable)

void

load_default_leaderboard_identifier(callback: Callable)

void

load_friends(callback: Callable)

void

load_friends_authorization_status(callback: Callable)

void

load_friends_with_identifiers(identifiers: PackedStringArray, callback: Callable)

void

load_recent_friends(callback: Callable)

void

register_listener()

void

resolve_conflicting_saved_games(conflicts: Array, data: PackedByteArray, callback: Callable)

void

save_game_data(data: PackedByteArray, withName: String, callback: Callable)

void

set_default_leaderboard_identifier(identifier: String, callback: Callable)

void

unregister_listener()


Signals

challenge_completed(player: GKPlayer, challenge: GKChallenge, friend_player: GKPlayer) 🔗

Emitted when the local player completes a challenge issued by friend_player.


challenge_other_player_accepted(player: GKPlayer, challenge: GKChallenge) 🔗

Emitted when another player accepts a challenge that the local player issued.


challenge_other_player_completed(player: GKPlayer, challenge: GKChallenge, friend_player: GKPlayer) 🔗

Emitted when friend_player completes a challenge issued by the local player.


challenge_received(player: GKPlayer, challenge: GKChallenge) 🔗

Emitted when the local player receives a new challenge.


conflicting_saved_games(player: GKPlayer, conflicting_saved_games: Array) 🔗

Emitted when there is a conflict between saved games. You should listen to this signal and then call resolve_conflicting_saved_games() with the chosen data.


exchange_canceled(player: GKPlayer, exchange: GKTurnBasedExchange, match: GKTurnBasedMatch) 🔗

There is currently no description for this signal. Please help us by contributing one!


exchange_completed(player: GKPlayer, replies: Array, match: GKTurnBasedMatch) 🔗

There is currently no description for this signal. Please help us by contributing one!


exchange_received(player: GKPlayer, exchange: GKTurnBasedExchange, match: GKTurnBasedMatch) 🔗

There is currently no description for this signal. Please help us by contributing one!


invite_accepted(player: GKPlayer, invite: GKInvite) 🔗

There is currently no description for this signal. Please help us by contributing one!


match_requested_with_other_players(player: GKPlayer, recipient_players: Array) 🔗

There is currently no description for this signal. Please help us by contributing one!


player_wants_to_quit_match(player: GKPlayer, match: GKTurnBasedMatch) 🔗

There is currently no description for this signal. Please help us by contributing one!


saved_game_modified(player: GKPlayer, saved_game: GKSavedGame) 🔗

Emitted when a saved game is modified.


turn_based_match_ended(player: GKPlayer, match: GKTurnBasedMatch) 🔗

There is currently no description for this signal. Please help us by contributing one!


turn_event_received(player: GKPlayer, match: GKTurnBasedMatch, did_become_active: bool) 🔗

There is currently no description for this signal. Please help us by contributing one!


Property Descriptions

bool is_authenticated = false 🔗

  • bool get_is_authenticated()

Reflects GKLocalPlayer.local.isAuthenticated.


bool is_multiplayer_gaming_restricted = true 🔗

  • bool get_is_multiplayer_gaming_restricted()

True when multiplayer is disabled by parental controls.


bool is_personalized_communication_restricted = true 🔗

  • bool get_is_personalized_communication_restricted()

Indicates whether personalized communication is blocked for this account.


bool is_underage = false 🔗

  • bool get_is_underage()

Apple’s isUnderage flag for COPPA-compliant flows.


Method Descriptions

void delete_saved_games(named: String, callback: Callable) 🔗

There is currently no description for this method. Please help us by contributing one!


void fetch_items_for_identity_verification_signature(callback: Callable) 🔗

Calls Apple’s fetchItems helper for server-side authentication. The callback receives (Dictionary data, Variant error). The dictionary contains the url, data, salt, and timestamp keys described in the inline Swift documentation, letting your backend verify the player’s identity. If not null, error contains a GKError.


void fetch_saved_games(callback: Callable) 🔗

Use this API to retrieve the list of saved games, upon completion, this

method invokes the provided callback with both an array of GKSavedGame objects

and a variant error, if not nil it contains a GKError describing the problem.


void load_challengeable_friends(callback: Callable) 🔗

Loads players whom the local user can challenge. The callback receives (Array[GKPlayer] friends, Variant error) where either argument can be null. If error is present, it is a GKError.


void load_default_leaderboard_identifier(callback: Callable) 🔗

Loads the local player’s current default leaderboard identifier.

The callback receives (Variant identifier, Variant error), where identifier is a String or null, and error is null or a GKError.


void load_friends(callback: Callable) 🔗

Fetches the friends list. The callback receives (Array[GKPlayer] friends, Variant error); a non-null error Variant holds the GKError.


void load_friends_authorization_status(callback: Callable) 🔗

Loads the authorization status for friend access.

The callback receives (int status, Variant error), where status is Apple’s raw GKFriendsAuthorizationStatus value.

Requires iOS 14.5, macOS 11.3, tvOS 14.5, or visionOS 1.0. Older versions return 0 plus an apiNotAvailable error.


void load_friends_with_identifiers(identifiers: PackedStringArray, callback: Callable) 🔗

Loads friends that match the provided scoped player identifiers. Pass them as PackedStringArray(["player_id_1", "player_id_2"]).

The callback receives (Array[GKPlayer] friends, Variant error), where error is null on success or a GKError.

Requires iOS 14.5, macOS 11.3, tvOS 14.5, or visionOS 1.0. Older versions return an empty array plus an apiNotAvailable error.


void load_recent_friends(callback: Callable) 🔗

Loads friends that recently played together with the local player. The callback signature matches load_challengeable_friends().


void register_listener() 🔗

Registers the local player listener to receive events like saved game conflicts. You typically call this in your _ready() function.


void resolve_conflicting_saved_games(conflicts: Array, data: PackedByteArray, callback: Callable) 🔗

Resolves conflicting saved games using the provided data. The conflicts array should contain the GKSavedGame objects that are in conflict (received from the conflicting_saved_games). The data is the correct game data to save. The callback receives (Array[GKSavedGame] saved_games, Variant error). error is a GKError if not null.


void save_game_data(data: PackedByteArray, withName: String, callback: Callable) 🔗

Saves the packed byte array as the game data with the specified name, upon

completion the callback is invoked with both a GKSavedObject parameter and

a Variant parameter for the error. The GKSavedObject is not-nil on success,

and on error, the second parameter is not-nil and contains the GKError.


void set_default_leaderboard_identifier(identifier: String, callback: Callable) 🔗

Sets the local player’s default leaderboard identifier to identifier.

The callback receives one argument: error, which is null on success or a GKError on failure.


void unregister_listener() 🔗

Unregisters the local player listener.