- Home /
Display equipment over network
Short version: I want to sync up each player prefab with the dummy prefab that represents the player on the other player's screens.
Long version:
Hello everyone! After having looked around for a while I decided to ask here since then I can check back here once in a while whilst I continue to search for an answer and thus make most of my time.
My question is this; How do I display what gear is equipped over the network?
Currently all gear is placed on my character and disabled, the way I show what gear the player is wearing is by enabling the wanted item when it has been equipped (I have a rather large system for this, but the basic thing is; The player double clicks an item in his inventory, it gets set to ".SetActive(true)" and it gets enabled in the scene.)
Now, this works in single player, but currently I'm migrating all my scripts and such to a multiplayer solution since that was my goal all along. But currently when I equip gear it gets;
shown on the other player connected. (It does not get shown to the other player, it just equips it on the dummy representing the other player in the game world)
not displayed over the network, so even if I manually go in and enable the gear on the character (In the editor) the new prefab look does not get sent over with the networkView
I apologize if I am confusing, unfortunantly I lack the proper know how of Unity's networking protocols to be able to explain more eloquently.
But the basic idea is;
I want to show the new look to everyone else connected to the server and currently, it does not.
If you need scrips or anything similiar please do say so I will post the relavant code if needed.
Thanks in advance to all your awesome people taking your time to help :)
Answer by jacobschellenberg · Jul 30, 2013 at 05:50 PM
RPC Buffer is perhaps exactly what you are looking for. Buffered RPC calls mean that any new user will receive the update upon connecting.
The problem is, it needs to update whilst the players are already connected. Because currently, I have a system where the player can equip items, it works by activating childobjects on the player that started out as non-active. So when they equip a sword or something like that, the sword child gets the "_swords[10].SetActive(true);", thus showing the sword as it should. But the problem is that the sword only shows on the client's side. Not server side.
I was sort of hoping I could do something similiar to what I did with the animation ($$anonymous$$aking a NetworkView and just dragging the Animation onto it) - Also, thank you very much for helping. Been stuck on this the entire day.
Network.Instantiate may be another option than. Ins$$anonymous$$d of turning the weapon on or off, you could Network.Instantiate it into the proper place. Honestly though, calling an RPC'd method should do the trick because the RPC is called for all connected on the network. However, give Network.Instantiate a try.
Thank you, I was hoping I didnt have to instantiate since its 89 different items thats on the character. I will put your answer as the correct one when I've verified the method.
Unfortunantly I cant use the method you suggested. After spending 3-4 hours playing around with trying to get my meshes to be placed correctly I've finally given up and I will try and find another way of updating the prefab. Thank you for your help regardless.
Your answer
Follow this Question
Related Questions
How to fix OnObjSpawn netId: 1 has invalid asset Id when using Lobby example in existing project 0 Answers
Instantiated objects not showing on new clients [uNet] 1 Answer
I have problem with synchronize multiplayer player position... 0 Answers
Changing the variable 'power' of ONE turret instead of ALL turrets 1 Answer
Prefabs spawn with wrong values 0 Answers