extends Node
var client : NakamaClient
var session : NakamaSession
var socket : NakamaSocket
var username = "example"
var play_service
func _ready():
if Engine.has_singleton("GodotPlayGamesServices"):
play_service = Engine.get_singleton("GodotPlayGamesServices")
play_service.init(true, true, true, "id")
play_service.connect("_on_sign_in_success", self, "ConnectToNakama")
play_service.connect("_on_sign_in_failed", self, "_on_sign_in_failed")
play_service.signIn()
func _on_sign_in_failed():
pass
func ConnectToNakama(profile):
client = Nakama.create_client('defaultkey', "ip", 7351,
'http', 3, NakamaLogger.LOG_LEVEL.ERROR)
var split = profile.split('"')
var id = split[11]
session = yield(client.authenticate_device_async(id, username), 'completed')
if session.is_exception():
print("connection has failed " + session.exception.message)
return
socket = Nakama.create_socket_from(client)
yield(socket.connect_async(session), "completed")
print("Connected!")
on
play_service.connect("_on_sign_in_success", self, "ConnectToNakama")
play_service.connect("_on_sign_in_failed", self, "_on_sign_in_failed")
altough I do succesfully sign in, the ConnectToNakama function is not running also when i write play_service.connect("_on_sign_in_success",self,(suggestions appear)) if i remove the
play_service.signIn()
the ConnectToNakama suggestion appears but the
func _on_sign_in_failed
suggestion still doesn't appear
and I can't sign in if i put the
play_service.signIn()
in another function what can I do? :c
Godot 3.5.1 Stable
The few things I can identify:
singInshould be inside theifstatement, here:That is because
play_servicewould only be initialized if the execution entered the if statement.On a similar note: make sure the indentation is correct. You could not be getting the suggestions because of a syntax error, such as wrong indentation.
The "_on_sign_in_failed" signal passes an
int. I claim this based on the source code at PGSGP. Thus you should declare the_on_sign_in_failedmethod with a parameter:I'm guessing that
ConnectToNakamais not running because it is trying to call_on_sign_in_failedinstead, but that is also failing because it is missing the parameter.They should not be necessary, but these are the types for "_on_sign_in_failed":
And for "_on_sign_in_success":