Godot Version
Godot 4.2.2 - stable
Question
Iam getting this error:
Invalid set index “multiplayer_peer” (on base: ‘null instance’) with value of type ‘ENetMultiplayerPeer’.
So i made the following code, and it works great when i try it in the editor, but when i try hosting and joining from 2 different device it send this error. I noticed it only send the error when there is already a client or host created from either device, so basically i can create the host, but can’t connect to it from the other device as it throw that error. Thanks for your help.
Here is the code:
var multiplayer_peer = ENetMultiplayerPeer.new()
const PORT = 1234
func _ready():
multiplayer.allow_object_decoding = true
func create_server():
multiplayer_peer.create_server(PORT)
multiplayer.multiplayer_peer = multiplayer_peer <-- Error Here
multiplayer.peer_connected.connect(_on_peer_connected)
multiplayer.peer_disconnected.connect(_on_peer_disconnected)
func join_server():
multiplayer_peer.create_client(get_ip(), PORT)
multiplayer.multiplayer_peer = multiplayer_peer <-- Error Here