0 votes

I followed some tutorial on Youtube and it seems everything worked for him, but in my end I keep getting this error:

The method "hide" isn't declared in the current class.

Here is my code:

extends Node

var address = "127.0.0.1"
var port = 3377

# Called when the node enters the scene tree for the first time.
func _ready():
get_tree().connect("network_peer_connected", self, "_player_connected")

func _on_ButtonHost_pressed():
    var net = NetworkedMultiplayerENet.new()
    net.create_server(port, 2)
    get_tree().set_network_peer(net)


func _on_ButtonJoin_pressed():
    var net = NetworkedMultiplayerENet.new()
    net.create_client(address, port)
    get_tree().set_network_peer(net)

func _player_connected(id):
    Globals.player2id = id
    var game = preload("res://Scenes/Game.tscn").instance()
    get_tree().get_root().add_child(game)
    hide()
    print("hello")

I have to put a hide() there after all players are connected so it would hide the Lobby scene (of which this script is attached to), then load the Game.tscn. Any way to fix this error? I already tried closing and re-opening Godot and it still gave me this error.

Godot version 3.2.3 Stable
in Engine by (12 points)

1 Answer

+1 vote

Your script extends Node. hide() is not a method of Node, it's a method of CanvasItem.

https://docs.godotengine.org/en/3.2/classes/class_canvasitem.html

by (20,677 points)
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 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 webmaster@godotengine.org with your username.