- Home /
Show prefab's children over network
Hello everyone,
So, I want to update the player prefab over the network, I have a playerPrefab that holds all clothing items as children, when the game runs, all children gets hidden unless they have become equipped by doing this;
private static void HideWristMeshes()
{
for (int i = 0; i < _wristMesh.Length; i++) {
_wristMesh[i].SetActive(false);
}
}
I have a method for each item category, all doing the same basic thing.
Now, when the player picks up an item and equips it
public static Item EquipedWrist
{
get{return_equipment[(int)EquipmentSlot.Wrist];}
set{_equipment[(int)EquipmentSlot.Wrist] = value;
HideWristMeshes();
if(_equipment[(int)EquipmentSlot.Wrist] == null)
{
return;
}
switch(_equipment[(int)EquipmentSlot.Wrist].Name) {
case "ElvenArmourWrist":;
_wristMesh[0].SetActive(true);
break;
case "MercWristArmour":
_wristMesh[1].SetActive(true);
break;
case "NordraicWristArmour":
_wristMesh[2].SetActive(true);
break;
case "TemplarWristArmour":
_wristMesh[3].SetActive(true);
break;
}
}
}
And this works just fine on the clients side. It shows everything it should and so on, but heres the problem.
I need to send a message to the rest of the players that suddenly the item "ElvenArmourWrist" has been set to "true", and should now be displayed as such.
How do I do this? This is my first try at using Unity's inbuilt networking solution so I am rather new. I have been reading up on as much as possible, but the problem is; I dont know where to apply the different methods and I'm unsure if I understand them correctly.
So I was hoping someone knew a way of updating the playerPrefab as soon as an item has been equipped. I thought that a networkView on the playerprefab would do the trick. But it seems the only thing a NetworkView updates is the rotation and position (Which works).
Hopefully someone can help.
(Ps. Before anyone says I should just network.instantiate the children onto the player as gameobjects, I've tried. The meshes are quite weird and I cannot get them to be positioned correctly. I am using a pre-made 3D model, and when ever I try to position them onto the character from the outside then they wont fit as they should. So I'm left with the only option of sending whether or not the child is visible or not.)
Thank you so much in advance :)
Answer by Etarnalazure · Aug 01, 2013 at 01:08 AM
Though this is not a "proper" answer, I will give an update on what I did to get it working;
I got a asset pack called "TNet" to solve my problem for me. Unfortunantly, it seems I dont have enough experience to create the server my way. So I took the 'easy' way out.
Your answer
Follow this Question
Related Questions
Problem with RPC attribute. 0 Answers
When to use OnSerializeNetworkView and RPC's 1 Answer
Multiplayer - Selected character to Network.guid? 0 Answers
Network Instantiate PlayerPrefab Problem 2 Answers
get return on networkView.RPC 1 Answer