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
0
Question by mathias512 · Jul 01, 2019 at 01:10 PM · androidmultiplayerissuemobile devicesmatchmaking

Player duplication when testing on android mobile Matchmaker system

Hello fine unity devs! I am developing a top down shooter multiplayer mobile game for android. My Unity version is 2018.3.0f2 and I am using NetworkLobbyManager to handle my lobby, Matchmaker and relay services for matchmaking. My lobby settings look like this: Link for picture of lobby settings

I get a weird player duplication glitch where out of 1 lobby player I get 2 ingame players when scene changes from offline to online, therefore creating more players than the lobby allows it in the settings where max players count is 4 players and in my online scene spawns 7 players as shown in the picture below: LinkForGlitchPicture

What i tried so far to solve this issue:

  • manually creating players with OnClientConnect, OnLobbyServerCreateGamePlayer and OnClientSceneChanged and disabled autocreate players tickbox in lobby but with no luck, issue persists. Code for manually creating players:

         public class MyLobby : NetworkLobbyManager
         {
         public override void OnClientConnect(NetworkConnection conn)
         { 
             Debug.Log("Caling OnClientConnect");
             ClientScene.Ready(conn);
             ClientScene.AddPlayer(0);
         }
     
     
         public override void OnClientSceneChanged(NetworkConnection conn)
         {
             base.OnClientSceneChanged(conn);
             Debug.Log("Caling OnClientSceneChanged");
         }
       }
    
    
  • tried to spawn a dupe empty game object when a player with same connection id was detected, didnt work properly. It sucessfully created dupes for duplicate player objects but it gave you control over that empty gameobject instead of the real/local player object. Which resulted in a black screen, because the dupes are empty objects and have no camera on them.

Code for spawning duped empty player objects:

     public class MyLobby : NetworkLobbyManager
     {
 //we use this variable to store connection id
     public int netCon=10;
 
     public override GameObject OnLobbyServerCreateGamePlayer(NetworkConnection conn, short playerControllerId)
         {
 
         //we check if the netcon value is different than the player that is being created, if its not then we have a dupe
         if (netCon != conn.connectionId)
         {
             GameObject _temp = Instantiate(PlayerCharacter, startPositions[conn.connectionId].position, startPositions[conn.connectionId].rotation);
             netCon = conn.connectionId;
             Debug.Log("Value of netcon is: " + netCon);
             return _temp;
         }
         else
         {
             GameObject dupe_temp = Instantiate(Dupe);
             Debug.Log("Spawned a dupe player");
             return dupe_temp;
  
 
            }
         }
     }

Any help with this issue would be much appreciated!

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

1 Reply

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

Answer by mathias512 · Jul 13, 2019 at 09:36 AM

Looked for a viable solution to this problem for a long time now (over 1 month), didnt find anything that could help. I managed to finally solve it by switching to PUN2. Everyone that has problems with Unet I recommend ditching it as soon as possible and not wasting time on fixing problems with Unet. I dont mean to sound toxic but Unet by now is basically so broken it cant be used for the simplest of network games.

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

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

295 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Matchmaking on Android, CLient doesn't create PlayerPrefab 0 Answers

Mobile transparency issue 0 Answers

Semaphore.WaitForSignal is causing so much lag on Android!!! Help!!! 1 Answer

AV Pro Video Playback Rewinding Issue -Android 0 Answers

Why on the mobile do the elements seem to have a very unstable position? 0 Answers


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