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 tavoevoe · Oct 12, 2012 at 11:39 PM · networkingnetworkview

AllocatedID error

I have a server and a client running the same code. I want X clients to be able to join a server. They all control a character (including the server) on a map. Pretty standard. I can allow players to connect and disconnect, but if they try to reconnect, they get two errors and weird stuff start happening. 1) View ID AllocatedID: 150 not found during lookup. Strange behaviour may occur 2) Could't invoke RPC function 'FocusCameraOnObject' because the networkView 'AllocatedID: 150' doesn't exist

I'm also going to dump the javascript file in question in here, but it may not really be nesessary.

 var playerModel : Transform;
 var mapModel : Transform;
 
 
 //add players and map
 function OnPlayerConnected(player: NetworkPlayer)
 {
     networkView.RPC("startLoadingSelf",  RPCMode.AllBuffered, player.ToString());
 }
 @RPC
 function startLoadingSelf(player:String)
 {
     if(Network.player.ToString() == player)
     {
         addNewPlayer("player " + player);
     }
 }
 
 function OnServerInitialized()
 {
     var newMapModel = Network.Instantiate(mapModel, transform.position, transform.rotation, 0);
     newMapModel.networkView.RPC("renameObject", RPCMode.AllBuffered, "Map");
     
     addNewPlayer("player " + Network.player.ToString());
 }
 
 function addNewPlayer(playerName:String)
 {
     
     var spawnPoint = GameObject.Find("Map/Spawn");
     var newPlayerModel = Network.Instantiate(playerModel, spawnPoint.transform.position, spawnPoint.transform.rotation, 0);
     newPlayerModel.networkView.RPC("renameObject", RPCMode.AllBuffered, playerName);
     newPlayerModel.networkView.RPC("FocusCameraOnObject", RPCMode.AllBuffered, playerName, playerName + "/PlayerModel");
 }
 
 
 
 //remove players and map
 function OnPlayerDisconnected (player : NetworkPlayer)
 {
     Network.RemoveRPCs(player);
     removePlayer("player " + player.ToString(), "network");
 }
 
 function OnDisconnectedFromServer(mode : NetworkDisconnection)
 {
     Destroy(GameObject.Find("Map"));
     var players = GameObject.FindGameObjectsWithTag("Player");
     var i = 0;
     for(var player in players)
     {
         removePlayer("player " + i, "local");
         i++;
     }
 }
 
 function removePlayer(playerName:String, netOrLoc:String)
 {
     if(netOrLoc == "network")
     {
         GameObject.Find(playerName).networkView.RPC("FocusCameraOnObject", RPCMode.AllBuffered, playerName, "World");
         Network.Destroy(GameObject.Find(playerName));
     }
     else if(netOrLoc == "local")
     {
         GameObject.Find(playerName).GetComponent(GenericRPC).FocusCameraOnObject(playerName, "World");
         Destroy(GameObject.Find(playerName));
     }
     var currentPlayer = GameObject.Find("World");
 }
 
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

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by tavoevoe · Oct 13, 2012 at 04:46 PM

I solved this on my own. Sorry if I wasted anyone's time. The trick here is that I'm calling removeRPCs, then adding one more RPC. That means, when a player connects after this player has left, they get one command that's applicable to a non-existent player. The two lines in the "OnPlayerDisconnected" function should be swapped.

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

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

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

Persisting NetworkView across Scene change does not work 1 Answer

Is server the sender of RPC? 0 Answers

A question regarding networking... 2 Answers

How to solve RPC error 1 Answer

Error from Serializing Non Network Instance 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