Doing some more debugging. I cant seem to make it work over network.
I have 2 machines, well one machine but with sandbox.
Each OS instance has its own IP
I can ping from one to another and vice versa
I can join from one to another
But when im listening on UDP port, i cant see other server. But i can join the server entering the IP.
I thought this sets up listener on all IP addresses
func set_up_listen():
listener = PacketPeerUDP.new()
var ok = listener.bind(listen_port)
if ok == OK:
print("Bound to Listen Port " + str(listen_port) + " Successfully")
else:
print("Failed to bind to Listen Port: " + str(listen_port))
But somehow it does not work.. or am i doing it wrong?
This is my _process() when app launches it starts doing this.
func _ready() -> void:
set_up_listen()
pass
func _process(delta: float) -> void:
if listener.get_available_packet_count() >0:
var server_ip = listener.get_packet_ip()
var server_port = listener.get_packet_port()
var bytes = listener.get_var()
var data_obj:RoomInfo = RoomInfo.from_dict(bytes)
print("Got packet: " + str(server_ip) + ":" + str(server_port) + " Room: " + str(data_obj.to_dict()))
if not server_ip: return
var server_info_node_name = str(server_ip) + "." + str(server_port)
server_info_node_name = server_info_node_name.replace(".","_")
if not server_list_container.has_node(str(server_info_node_name)):
var new_server_info:ServerInfoContainer = SERVER_INFO_CONTAINER.instantiate()
new_server_info.join_button_pressed.connect(join_button_pressed)
if data_obj.server_ip == "127.0.0.1":
new_server_info.server_ip= server_ip
else:
new_server_info.server_ip = data_obj.server_ip
new_server_info.server_port = data_obj.server_port
new_server_info.server_name = data_obj.room_name
new_server_info.player_count = str(data_obj.player_count)
new_server_info.name = server_info_node_name
server_list_container.add_child(new_server_info)
else:
var new_server_info:ServerInfoContainer = server_list_container.get_node(server_info_node_name)
if data_obj.server_ip == "127.0.0.1":
new_server_info.server_ip= server_ip
else:
new_server_info.server_ip = data_obj.server_ip
new_server_info.server_name = data_obj.room_name
new_server_info.player_count = str(data_obj.player_count)
EDIT: Sorry for video compression, it was filmed between 2x 2k monitors so i guess it got automagically compressed when i uploaded it.
But in the video i jaunch 2x godot.exe instnaces and one joins the other, but when when i start hosting they should see the server in the list but it does not show up. Only the local (current machine) server shows up in the list.
It seems im not getting no packets when i set the IP to the other machine.
func set_up_listen():
listener = PacketPeerUDP.new()
var ok = listener.bind(listen_port,"*")
if ok == OK:
print("Bound to Listen Port " + str(listen_port) + " Successfully")
else:
print("Failed to bind to Listen Port: " + str(listen_port))
What could be the culprit?