godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.89k stars 20.16k forks source link

get_peer_address/port does not work #38537

Closed NuxaHD closed 4 years ago

NuxaHD commented 4 years ago

Godot version: 3.2.1 OS/device including version: Windows 10 Issue description: I use NetworkedMultiplayerENet for Multiplayer

An error occurs when two clients are running on the same device

Unbenannt

am I doing something wrong? or is this function only for the serverside?

Steps to reproduce: use the NetworkedMultiplayerENet

(network_peer_connected and network_peer_disconnected)

func _player_disconnected(id): print("The player "+ str(players[id].name) + " (" +str(get_tree().get_network_peer().get_peer_address(id))+ ":" +str(get_tree().get_network_peer().get_peer_port(id))+") left the server")

Faless commented 4 years ago

As the error mention, only the server can get the address and port of other clients. This is due to the client/server architecture of the ENet implementation in Godot which is not P2P, and does not, by default, send those information to the clients (you can do that manually if you so desire, by sending an RPC from server to other clients with those information).