Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by rahulgameOn · Dec 16, 2016 at 03:06 PM · androidunity 5photonmultiplayer-networkingtcpclient

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by Brijs · Dec 16, 2016 at 07:00 PM

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image rahulgameOn · Dec 16, 2016 at 08:39 PM 0
Share

Thanks a lot. This was what I needed :-)

avatar image KartikNK · Jan 11, 2018 at 05:39 PM 0
Share

@Brijs I,m developing an android game via Wifi and new to UNET as well, that's why I am unable to implement the steps mentioned above, it'd be great if you present a sample code for it. Please help me.

avatar image
0

Answer by Chinmay_Gawande · Sep 09, 2017 at 02:41 AM

BRIJIS THANKS A LOT U SAVED MY LIFE

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by hamedham · Feb 13, 2018 at 04:15 PM

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!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by harikrishnan_annappilly · May 19, 2018 at 05:45 PM

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mansoor090 · Feb 20, 2019 at 12:23 PM 0
Share

you need to see yaseen mujahid photon pun tutorial . there are only 4 videos . 5th is an extra one i havent use Unity own multiplayer system but you will get an idea what problem is there in photon u need to disable scripts of other players

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Photon network won't join random room with a custom property 0 Answers

Photon objects not syncing 1 Answer

Light.color Sync ? 1 Answer

unity photon 2 not activate child of specific spawned player 0 Answers

Unity Photon:How do i get other player's photonnetwork.player.id when a player collide with other player? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges