Android mobile local multiplayer game via Wifi

Hi,

I am new to Unity Networking. I have been searching since past few days on how to connect my mobile with my friend’s mobile via wifi for playing games. I want it to stay offline( no internet), ie, I dont want any Master Server like UNet or Photon uses.
I researched a bit on UNet 5. They provide a way through which we can connect to the host on the same LAN network by specifying the the IP Address of the host.

My question is- Is there any way by which I can connect to the host without specifying the IP Address of the host. Since we are not using any kind of master server, It seems that there is no way we can keep a track of all the hosts created on the given LAN. Or if there is any way please let me know.

But still if you see doodle army mini militia, you will find that they have a way in which they can search through all the hosts created on the given LAN network. In mini militia, we create a wifi hotspot and all the other players join the same wifi network. Then One of the player hosts the game and all the other players joins the game without any trouble of putting the IP address.

I want the same functionality in my android game. The much i researched, it seems that its not possible by using UNet or Photon. I am not sure if I am correct or not. I went through many forums QA, but I could not get the answer to my question. I would be really glad if you could help me out.

Use NetworkDiscovery class of UNET.

  1. Set broadcastData (going to be delivered to listeners) on host before starting broadcast.

  2. Call Network discovery methods as written in NetworkDiscovery class doc and override OnReceivedBroadcast method as shown in doc. This method is called on clients when it listens broadcast from host/server.

  3. OnReceivedBroadcast method has 2 parameters. First parameter is IP(of host/server) which is used to establish connection to server and second parameter data(can be host name) is broadcast data which is set in first step.

Now you have the IP of host /server so you do not have to specify IP address to connect to host.

This may help you.

BRIJIS THANKS A LOT U SAVED MY LIFE

I think Every of answerers knows that which way is good for wifi connection t but no one of them can write an example code. thay doesnt know how to use it!

So i just build a multiplayer game,I was planing to make a android version of it. So i included some UI buttons to it. But then i notices that Canvas wont piking the prefabs so i just put the canvas,buttons and event manager as child of the player charecter. It worked but then i see that it wont work as expected when connecting multiple devices. It is only able to control the latest player with latest deveice joined(latest means the last one which joined the game). So can some one help me to solve this ! Thank you