How can I search for players in the same wifi in Unity?
I am creating a game in Unity and I would like to create an ability for players to join the game that others have created on the same wifi. I would like it to be as effortless as possible(e.g. players don't have to find out their wifi, etc). The game is cross-platform - you could have one player on PC, other on Android device, etc. Now I know that there is a game that has similar mechanism to what I would like to achieve: SpaceTeam. Basically you select whether you use BT or wifi, and wait for other players to join. How can I do this in Unity, or something similar that satisfies my needs?
A UDP datagram sent to the broadcast address is delivered to all nodes on the LAN.
I don’t normally do networking in C# but it should go something like this:
First, listen for packets with any destination address.
new IPEndPoint(IPAddress.Any, ...)
Now, send packets to the broadcast address:
new IPEndPoint(IPAddress.Broadcast, ...)
These packets will be received by every machine behind the same router, via WiFi or Ethernet.
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Entertainment & General News
- Games & eSport