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 arn1471 · Apr 22, 2013 at 07:39 PM · spawnnetwork.instantiateviewid

Late join Auth Server Instantiation - ViewID issues?

Walloftext.net

reviously in my development I had used the Network.Instantiate function to spawn my players. I also had incorporated a lobby that allowed players to set up and chat to other players before actually commencing gameplay. When I attempted to use this to allow late players to join I ran into issues with its buffered nature. So I set about coding my own instantiate system that allowed me to spawn and set up games for players whenever I wanted.

At the moment I have what I assumed to be a working method to capture store and update a newly connected player. When a player joins my server it asks to be updated on currently connected players and then requests to be spawned itself. From what I could understand from googling and trawling this website for answers i needed to allocate the View Id's like network.Instantiate on my own.

My understanding is limited but i figured i could allocate the ViewID to an array when a player requests to spawn (which works and is not buffered so as people join and as new ID's are allocated they are assigned and everything is sync'd and stored. My problem comes when i try to instantiate the current players for the newly joined player. I figured i could save the ViewID's of the players spawn the player objects and assign the correct ID to each player. The game would try to update that ID and hey presto. Unfortunately thats not the case. Despite the ID being the correct one and been assigned to the right player object it fails to update itself and throws update ID errors about its initial state being wrong.

I assume this is because i fail to attach it and i should use groups to stop the messages being updated for these players but i also figured atleast when it spawned and assigned the ID it would then begin to update it. However this is not the case.

I have to be missing something vital :/ but i cant gleem any more information from the documentation or from various partially appropriate questions.

This is essentially the management script on all players clients/the server that controls communication to the server and the spawning of playerobjects. Its paraphrased and rewrote so ignore spelling mistakes, caps errors and missing parameters and such.. focus on the principle of the code to late network instantiation instead of its debugging issues!

 onnetworkplayerconnected(){
 
 if(server){
 spawnPlayer();
 addToSpawnList();
 
 }else{
 networkView.RPC("SpawnConnectedPlayers",RPCMode.Server)
 networkView.RPC("requestSpawn",RPCMode.Server)
 }
 
 }
 
 
 @RPC
 function spawnPlayer(Loc:Vector3, ViewID : NetworkViewID){
 var go : GameObject = GameObject.Instantiate(PlayerGameObject,loc,Quaternion.identity);
 go.networkView.viewID = ViewID;
 }
 
 @RPC
 function requestSpawn(PlayerID : String, NP:NetworkPlayer){
 if(CheckSpawnedList()){
 viewID = networkView.AllocateViewID;
 networkView.RPC("SpawnPlayer",RPCMode.All,GetSpawnPoint(),viewID);
 addToSpawnList(PlayerID);
 }
 }
 
 @RPC
 function SpawnConnectedPlayers(NetworkPlayer,PlayerID){
 
 for(var i : int; i<SpawnList.Length;i++){
 
 if(SpawnList[i] is NotMe && NotNull){
 networkView.RPC("SpawnPlayer",NetworkPlayer,GetSpawnPoint(),SpawnList[i].ViewID);
 }
 
 }
 
 }
 
 function addToSpawnList(PlayerID, NetworkPlayer, ViewID){
 for(var i : int; i<SpawnList.Length;i++){
 if(SpawnList[i].PlayerID == null){
 SpawnList[i].PlayerID = PlayerID;
 SpawnList[i].NetworkPlayer = NetworkPlayer;
 SpawnList[i].ViewID = ViewID;
 break;
 }
 }
 }
 `


What i know:

  • Late joining players update and appear for current players with no issues.

  • Current players are created and the network view assigned but the state messages sent are ignored from the clients owner on the new players game because of an initial state error?

  • All viewID's are correct on the late joined player when the client spawns the current players for them.

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

0 Replies

· Add your reply
  • Sort: 

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

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

How do I GetComponent from a NetworkView? 0 Answers

UNET The clients can't see the game object 0 Answers

Network.Instantiate spawns multiple objects 2 Answers

SpawnWithCLientAuthority Issues... 0 Answers

[Command]-Function By Client is not called on Server 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