|Topic was automatically imported from the old Question2Answer platform.
I want to try making an two android devices connect each other and play game with passing data.
one device create an hotspot and other second device connect using wifi with created hotspot device.
How can achieve this one in Godot?
Provide me source code or any document to full-fill this one.
i try using PacketPeerUDP to pass packages but it’s not work in devices.
use ip: 127.0.0.1 OR 188.8.131.52 OR connected device ip
Use Godot’s MultiplayerAPI as it’s easier to setup and you don’t have to bother with low level stuff like sending and polling packets
If you haven’t already please read High level Multiplayer and as for script Ping Pong is an excellent place to start
IP.get_local_addresses() to get the device’s ip
The way Android is setup Data takes priority then wifi then localhost and on some devices Bluetooth registers as an interface and takes priority. So make sure all are off except the one you want to use or if you’re familiar with Unix peripherals you can use
IP.get_local_interfaces() instead and filter by interface name
On the device that creates the server do
network_peer.set_bind_ip(MY_DEVICE_IP) before the
create_server call and use that as the server for the other peers to connect to
Unlikely that you will need to for a debug build but remember to also enable internet related permissions
Thank you for give me boost information.
Shailesh dhaduk | 2021-05-08 12:46
High level multiplayer configure:
IP.get_local_addresses() its always get local ip 127.0.0.1 in device,
this local ip to create server (host) alway throughout error in device but emulator work.
I know it’s return array but which ip used for MY_DEVICE_IP ??? [how can i identifier ip from array]
also peer.create_client(SERVER_IP, SERVER_PORT)
enter SERVER_IP hard code on join time ?
Shailesh dhaduk | 2021-05-10 08:16
SERVER_IP has to be the address of the device that is hosting and made the call to
network_peer.create_server() make sure to use
network_peer.set_bind_ip() first on that device
Assuming you’re using DHCP, Android device ips are structured this way
192.168.53.1 hotspot (wifi)
192.168.53.129 hotspot (usb)
So in the list returned by using
IP.get_local_addresses() just select the appropriate one
Wakatta | 2021-05-11 19:44