- Home /
TargetRpc not sending atribute (Mirror)
Note: Everywhere u see "cartes" it's same as cards.
Okay so i have some code witch is only executed on the server and it chooses witch cards each player will have and then stores them to a list (CartesP1, CartesP2...). When all the Lists are complete i call a method called "GiveCards" witch has a for loop that passes the CartesPx list to the corresponding player:
private void GiveCards()
{
for(int i = 0; i < Room.GamePlayers.Count; i++)
{
List<GameObject> CartesToPass = new List<GameObject>();
switch (i)
{
case 0:
CartesToPass.AddRange(CartesP1);
break;
case 1:
CartesToPass.AddRange(CartesP2);
break;
case 2:
CartesToPass.AddRange(CartesP3);
break;
case 3:
CartesToPass.AddRange(CartesP4);
break;
case 4:
CartesToPass.AddRange(CartesP5);
break;
case 5:
CartesToPass.AddRange(CartesP6);
break;
case 6:
CartesToPass.AddRange(CartesP7);
break;
case 7:
CartesToPass.AddRange(CartesP8);
break;
}
NetworkIdentity playerIdentity = Room.GamePlayers[i].gameObject.GetComponent<NetworkIdentity>();
Room.GamePlayers[i].TargetGetCards(playerIdentity.connectionToClient, CartesToPass);
Debug.Log("CartesPassed");
CartesToPass.Clear();
}
}
This method as you see calls the "TargetGetCards" method of the player script. This TargetGetCards method has 2 atributes, the NetworkConnection to kjnow witch client the playes is the localplayer and the list "cartesToPass", this method looks like this:
[TargetRpc]
public void TargetGetCards(NetworkConnection Conn, List<GameObject> Cartes)
{
MyCards.AddRange(Cartes);
}
This then adds all the objects from the "CartesToPass" list to a local list called "Mycards".
Now my problem is that, while the list seems to get through, as i can see MyCards gets 4 slots in the inspector (yes, i only give 4 cards to each player), the list is filled with empty gameobjects. This proves that the player gets the list as it adjusts the size of it to the correct number but it dosn't seem to get the gameobjects and i don't know why.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Using Mirror Networking, is there a "Run Everywhere" attribute? 1 Answer
[Mirror Networking] NullReferenceException on player when trying to start server a second time 1 Answer
Why Does Adding to My SyncListStruct Break SyncVar? 0 Answers
SyncVar on objects in a list 1 Answer