Invalid call. Nonexistent function 'authenticate_email_async' in base 'Nil'. (BUT EXISTS)

Hi guys, I’m implementing my nakama connection system in Godot 4. And currently I’m facing this problem:

When I try to call the “authenticate_email_async” function.
I get this “Invalid call. Nonexistent function ‘intance’ in base ‘Nil’.” It is possible that it is a silly mistake on my part, but I have been googling and I have not found a solution, I leave you the images so that you can see that everything is in order (in my opinion) and that it should be working. Thanks in advance.

in Online I have:

var nakama_client: NakamaClient :
	get:
		return nakama_client # TODOConverter40 Copy here content of get_nakama_client
	set(mod_value):
		mod_value  # TODOConverter40 Copy here content of _set_readonly_variable

And Online is a singelton.

Hi @sergisnt,

It looks to me as though your setter is wrong for nakama_client. You’re missing the assignment.

set(mod_value):
  nakama_client = mod_value

I’ve tried but the error persists…

I also tried a thing I saw on the Godot forum.

# For other scripts to access:
var nakama_client: NakamaClient :
	get:
		return nakama_client 
set(mod_value):
		nakama_client = _set_NC(mod_value) 

func _set_NC(value: NakamaClient) -> NakamaClient
         return value

But the error persist

I realized this. All those variables are null.

(SOLUTION) I have found a solution (Although I don’t know if it is the correct way, but it works) The problem is that the client was getting null all the time. And I had to load this get_nakama_client function like this and add it to the return.

func get_nakama_client() -> NakamaClient:
	var NC: NakamaClient
	
	if NC == null:
		NC = Nakama.create_client(
			nakama_server_key,
			nakama_host,
			nakama_port,
			nakama_scheme,
			Nakama.DEFAULT_TIMEOUT,
			NakamaLogger.LOG_LEVEL.ERROR)
	
	return NC

image

I don’t know if I should apply any changes to the set, but for now everything works fine.

Hi @sergisnt,

I’m glad you got it working. I would point out though that this does not appear to be a Nakama issue and is instead an issue with the Godot code in your project.

For example, the getter you have implemented will always create a new Nakama client (e.g. NC will never not be null during the if statement because you have only just defined it at the top of the get_nakama_client function so the Nakama.create_client will always happen); this in turn means your setter nakama_client = mod_value isn’t really doing anything useful because the underlying value of nakama_client is never used.

For a good example of implementing Nakama in Godot I would advise looking at our Fish Game example project.