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