+1 vote

I don't understand the behaviour of


if I'm in a Node2D, get_tree().is_network_master() doesn't give me an error message and returns a boolean
if I am in an Area2D child of the Node2D get_tree().is_network_master() gives me this error:

Invalid call. Nonexistent function 'isnetworkmaster' in base

However both inherits from Node which contains this isnetworkmaster() method???

In Area2D


without get_tree() doesn't return a message. Is this last syntax reliable, since I don't give a base to the method?

Thank you

in Engine by (72 points)
edited by

1 Answer

+2 votes
Best answer

Are you sure you're not confusing is_network_master() and is_network_server()?

The first one is a method on Node, or anything that inherits from it. The second is a method on a SceneTree, which is returned by get_tree().

I'd expect a call to is_network_master() to return an error if you call it on an instance of a SceneTree, which you appear to be doing above...

by (19,238 points)
selected by

Yeah, I got confused when I looked in the doc. But it is is_network_master that I'm trying to use.

I just checked in the doc there is well in Node:
bool isnetworkmaster ( ) const

In an area2d is_network_master() alone doesn't return an error but with the prefix get_tree() there is an error, it is normal.

So this is the correct use of isnetworkmaster

Sorry, I got it all mixed up. Thank you

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.