• 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 Oct 11, 2012 at 09:14 PM by KiraSensei for the following reason:

The question is answered, right answer was accepted

avatar image
Question by KiraSensei · Oct 05, 2012 at 10:01 PM · networkingmultiplayernetwork

Client can't modify a gameobject from server

Hello !

I have a network problem : my multiplayer game contains a scene where every player converge just before starting the real game. There is a chat in it and some texts meshes which (should) display the name of the players connected.

At first, a player creates a server and comes first in this scene. Then an other player connects to it and comes to this same scene. The chat is actually working, so they are clearly well connected...

In this waiting room scene, there is a game object with only this script attached :

 var playersList:PlayersList;
 
 class PlayerData {
     var nickname:String;
     var kills:int = 0;
     var deaths:int = 0;
 }
 
 class PlayersList {
     var players:PlayerData[] = new PlayerData[8];
     var maxNbPlayers = 0;
     var currentIndex = 0;
 }
 
 function Start() {
     if (!Network.isServer)
     {
         networkView.RPC("SendNickname", RPCMode.Server);
     }
     else
     {
         playersList.maxNbPlayers = Network.maxConnections;
         networkView.RPC("SendNickname", RPCMode.All);
     }
 
 }
 
 @RPC
 function SendNickname() {
     var name:String = PlayerPrefs.GetString("Player Name");
     
     if (playersList.currentIndex == playersList.maxNbPlayers) return false;
     
     playersList.players[playersList.currentIndex].nickname = name;
     playersList.currentIndex++;
     return true;
 }


As you can see, when the server is created, it sends to himself its nickname threw the gameobject containing the players data. Then when a players connects to this server, it sends its nickname too, but the gameobject is not updated in the server's scene ! I don't understand why ...

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
Best Answer

Answer by KiraSensei · Oct 11, 2012 at 09:14 PM

I found the solution bu myself. That was quite a stupid problem actually ...

The clients were reading their own playersList variables (and this is normal). I have to give specifically the players names from the server only to the clients threw RPC method. Then it works.

Comment

People who like this

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

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

9 People are following this question.

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

Related Questions

Unity networking tutorial? 6 Answers

You may not be connected when initializing security layer. 1 Answer

Offline testing a player object? 0 Answers

Network.Destroy doesn't remove objects on other systems? 2 Answers

Animation & sound over network 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