Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Joahun · Mar 11, 2015 at 09:33 AM · multiplayerlevelload

Networking

Hello!

So i'm working on a multiplayer game and im stucked. I started learning the networking part about a month ago and now i have a stable basic understand about it. I want to make an authoritative server but somehow players cant see each other. I spawn the characters via Network.Instantiate but they end up with all different viewID's. The first palyer has 51 the second one who joins got 201 the third one has 301... shouldn't be it the same for all to see each other? Here is my code so far I want to keep evriting simple so i can understand it easily.

 private var refreshing : boolean;
 private var hostedData : HostData[];
 var player : GameObject;
 var myplayer : NetworkPlayer;
 function Start ()
 {
     DontDestroyOnLoad(gameObject);
 }
 
 
 function Update ()
 {
     if(refreshing)
     {
         if(MasterServer.PollHostList().length >0)
         {
             hostedData = MasterServer.PollHostList();
             refreshing = false;
         }
     }
 }
 
 function OnGUI ()
 {
     if(!Network.isClient && !Network.isServer)
     {
         if(GUI.Button(Rect(10,10,100,30),"Start Server"))
         {
             Network.InitializeServer(16,25000);
             MasterServer.RegisterHost("Authiritative Testing", "Joa test game");
         }
         
         if(GUI.Button(Rect(10,50,100,30),"Find Game"))
         {
             MasterServer.RequestHostList("Authiritative Testing");
             refreshing = true;
         }
         
         if(hostedData)
         {
             for(var i : int = 0; i < hostedData.length; i++)
             {
                 if(GUI.Button(Rect(100,100,150,30), hostedData[i].gameName))
                 {
                     Network.Connect(hostedData[i]);
                     
                 }
             }
         }
     }
     
     if(Network.isServer)
     {
         GUI.Label(Rect(10,10,100,100),"This is a server now! Run a nother coppy of this application if you want to join.");
     }
 }
 

 
 
 
 
 
 ///////////////////////////////////////////////Debugging!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 function OnServerInitialized ()
 {
     print("server initialized");
 }
 
 function OnMasterServerEvent (mse:MasterServerEvent)
 {
     if(mse == MasterServerEvent.RegistrationSucceeded)
     {
         print("Registered server");
     }
 }
 
 

So what i want to achive is i want a menu scene where this script is attached to an empty game object and when the player starts a server it loads the first lvl but nothing more because i want it to be only the server and then palyers have to start a nother coppy to join in.

When somebody connect i want them to load the fist level(there will be one big map) and start to paly. I used an RPC whn somebody connected the server sent them wich level they sould load and also to set the evel prefix but players couldnt see each other. then i tried it whitout the level loading so players would instantiate on the menu level but the result was the same. I know there is a way to set the viewID manually but i couldnt find a tutorial or a sample code on how to do it.

If someone could explain it to me or show an example that would be great! Thank you for your answers!

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

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

DontDestroyOnLoad resets my variables 1 Answer

Multiple player spawnpoints 0 Answers

Network.InitializeServer doesn't work over Internet 0 Answers

Unity Multiplayer Design. Is it complicated to implement and learn? 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