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

The question is answered, right answer was accepted

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

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

Can i make multiplayer game without unity multiplayer service ? 1 Answer

Networking Player Nametag 1 Answer

When connected to a server, can other players access my static variables and/or public variables? 2 Answers

How to make a LAN game in Unity 2019.1.0f2 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