Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Pau678 · Oct 13, 2020 at 07:32 PM · networkinglistmirrorattribute

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.

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

189 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Using Mirror Networking, is there a "Run Everywhere" attribute? 1 Answer

A node in a childnode? 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

Foreach - what am I doing wrong? 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