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

Other

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

No state update from client (Network)

Hello, I have small network connection script, which 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 refreshing: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);
     refreshing = true; 
 }
 
 function Update()
 {
     if(refreshing)
     {
         if(MasterServer.PollHostList().Length > 0)
         {
             refreshing = 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
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

  • Sort: 
avatar image
0

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 something 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 something else, the check would fail.

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 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.

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

Download pictures and store them temporarily 1 Answer

ClientScene.AddPlayer resulting in 'Unknown message ID' error 1 Answer

Can you tell OnSerializeNetworkView who the owner is? 3 Answers

Get RPC senders ID, or IP? 1 Answer

Trying to store a variable for all clients 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