Hi! Cool to see a Godot forum again!
Post: https://godot.community/topic/184/problem-with-using-code-from-godot-3-x-to-4-1-1-with-connect?_=1700229697888
alexander the great
Posts
-
-
I'm using 4.1.1 stable,
get_tree().network_peer_connected.connect(_player_connected) get_tree().network_peer_disconnected.connect(_player_disconnected) get_tree().connected_to_server.connect(_connected_to_server)
the first 2 lines seem to have worked (weirdly) and yes I get the error:
Line 11:Identifier "_connected_to_server" not declared in the current scope.What could I use to get around this problem?
This is the tutorial I'm following:
Godot 3 Networked Multiplayer Shooter Tutorial -
I am trying to make a multiplayer 2D shooter following a tutorial but the tutorial is using version 3.2.3. The code in version 3.2.3 is:
extends Control @onready var multiplayer_config_ui = $Multiplayer_configure @onready var server_ip_address = $Multiplayer_configure/Server_ip_address @onready var device_ip_address = $CanvasLayer/Device_ip_address func _ready() -> void: get_tree().connect("network_peer_connected", self, "_player_connected") get_tree().connect("network_peer_disconnected", self, "_player_disconnected") get_tree().connect("connected_to_server", self, "_connected_to_server") device_ip_address = Network.ip_address func _player_connected(id) -> void: print("Player " + str(id) + " has connected") func _player_disconnected(id) -> void: print("Player " + str(id) + " has disconnected") func _on_create_server_pressed(): multiplayer_config_ui.hide() Network.create_server() func _on_join_server_pressed(): if server_ip_address.text != "": multiplayer_config_ui.hide() Network.ip_address = server_ip_address.text_changed Network.join_server()
however I get the error:
Line 9:Invalid argument for "connect()" function: argument 2 should be "Callable" but is "res://Network_setup.gd".
Line 9:Cannot pass a value of type "String" as "int".
Line 9:Invalid argument for "connect()" function: argument 3 should be "int" but is "String".on lines 9, 10 and 11. I have seen some other ways people have fixed it with timers but don't know how they would apply to this:
Gdscript connect() function
Join the _init() User Group - Exclusive for Our First 100 Members!
Problem with using code from godot 3.x to 4.1.1 with connect()
Problem with using code from godot 3.x to 4.1.1 with connect()