error with get_tree().is_network_master()

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By patlol

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 ‘is_network_master’ in base

However both inherits from Node which contains this is_network_master() 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

:bust_in_silhouette: Reply From: jgodfrey

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…

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 is_network_master ( ) const
Node — Godot Engine (latest) documentation in English

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 is_network_master

Sorry, I got it all mixed up. Thank you

patlol | 2020-02-14 23:49