• 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 /
This question was closed Nov 13, 2015 at 08:32 PM by BuZZy for the following reason:

Other

avatar image
Question by BuZZy · Mar 17, 2013 at 06:33 PM · networkserverclient

No state update from client (Network)

Hello, I have small network connection script, w$$anonymous$$ch starts server and connects other player to it. In my scene I have cube with NetworkView component attached. So my problem is, when I start server and other player connects, the cube sends state update only from server. What I mean is when I move cube as server it moves on both server and client windows, but when I move it as client it moves only on client's window. What could cause that? By the way, if client spawns that cube, then cube sends state update to server as it should.

Here's my script:

 private var refres$$anonymous$$ng:boolean;
 private var hostData:HostData[];
 
 private var btnX:float;
 private var btnY:float;
 private var btnW:float;
 private var btnH:float;
 var gameName:String = "MP_Project";
 var Helicopter:GameObject;
 function Start()
 {
     btnX = Screen.width * 0.05;
     btnY = Screen.height * 0.05;
     btnW = Screen.width * 0.1;
     btnH = Screen.width * 0.05;
 }
 
 function startServer()
 {
     Network.InitializeServer(32, 25001, !Network.HavePublicAdress);
     MasterServer.RegisterHost(gameName, "MP_Project", "The MP");
 }
 function refreshHostList()
 {
     MasterServer.RequestHostList(gameName);
     refres$$anonymous$$ng = true; 
 }
 
 function Update()
 {
     if(refres$$anonymous$$ng)
     {
         if(MasterServer.PollHostList().Length > 0)
         {
             refres$$anonymous$$ng = false;
             Debug.Log(MasterServer.PollHostList().Length);
             hostData = MasterServer.PollHostList();
         }
     }
 }
 
 function OnServerInitialized()
 {
     Debug.Log("Server initialized");
 }
 

 
 function OnMasterServerEvent(mse:MasterServerEvent)
 {
     if(mse == MasterServerEvent.RegistrationSucceeded)
     {
         Debug.Log("Registered");
     }
 }
 
 function OnGUI()
 {
     if(!Network.isClient && !Network.isServer)
     {
         if(GUI.Button(Rect(btnX, btnY, btnW, btnH), "Start Server"))
         {
             startServer();
         }
         if(GUI.Button(Rect(btnX, btnY*1.2 + btnH, btnW, btnH), "Refresh Hosts"))
         {
             refreshHostList();
         }
         if(hostData){
             for (var i:int = 0; i<hostData.length; i++)
             {
                 if(GUI.Button(Rect(btnX*2+btnW, btnY*1.2 + (btnH * i), btnW * 3, btnH*0.5), hostData[i].gameName))
                 {
                     Network.Connect(hostData[i]);
                 }
             }
         }
     }
 }
Comment

People who like this

0 Show 0
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

  • Sort: 
avatar image

Answer by xiaopewpew · Mar 29, 2013 at 07:12 PM

I see you copied the code from a tutorial straight away.

I would say the problem lies in other parts of the code, you probably had somet$$anonymous$$ng like networkview.ismine in the update part of your code. So update is only sent if the client/server itself initialised the object. If the object is initialised by somet$$anonymous$$ng else, the check would fail.

Comment

People who like this

0 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 BuZZy · Mar 30, 2013 at 12:27 AM 0
Share

I already realised, that I was trying to do the impossible. Because only owner of the object can send it's state update.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

11 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

Related Questions

Trouble with Server Client connection 1 Answer

how to create a simple udp network to send text data c# 0 Answers

Network Connections in Editor 1 Answer

Is there any difference calling Network.Disconnect or Network.CloseConnection from client? 1 Answer

May I control the game of a client through pressing some GuiButtons in the server application? 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