i need to connect to two different devices

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

im a noob about networking just started multiplayer stuff, networking. and i really know nothing but i watched this video https://youtu.be/K0luHLZxjBA and decided to try out. it went well but i did this in scuffed 2D i really didn’t care how it looks i just wanted to test if this actually works. and suprisingly it worked on the same machine tho. but now i’m trying to connect two different devices via local network but doesn’t seem to be working well. hope anyone can help
this the project almost the copy of the video but with a little different game mechanics
https://github.com/ash-hashtag/veryverysimplemultiplayer.git

:bust_in_silhouette: Reply From: Wakatta

A Multiplayer noob? Skipping a few steps i see.

In your Node2D.gd set the ‘ip’ var to be that of the ‘host’ on both devices as “127.0.0.1” is assgined to be localhost

This can be found out in a multitude of ways with the easiest being to call IP.get_local_addresses() or IP.get_local_interfaces() and selecting the appropriate one

On the host device (the one designated as server) also do

net.set_bind_ip(ip)

Unrelated


not important but the lines in game.gd

var p1 = preload("res://player.tscn").instance()

and

var p2 = preload("res://player.tscn").instance()

Seems weird to preload the same Packed scene twice so it should be like

var player = preload("res://player.tscn")
var p1 = player.instance()
var p2 = player.instance()