Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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
1
Question by Dudledok · Jul 15, 2015 at 11:14 AM · c#networkingnullreferenceexceptionunity multiplayer

Parameter becomes null through UNet Rpc

Below is a fragment of my code where the Rpc is called. You can see that I am doing some extra checks to make sure that the parameter being passed is not null by making a new copy of the dictionary I want to pass and then adding a value and to top it off a quick log so I can see in the editor there's no funny business.

 Dictionary<int, float> parameter = new Dictionary<int, float>(resources);
 
 if(parameter != null)
     Debug.Log("resources != null");
 else
     Debug.Log("resources == null");
 
 parameter.Add(1, 4.3f);
 
 if(networkController.isServer)
 {
     networkController.RpcSendRList(parameter);
 }

When running this as the server or the client, parameter is logged as not being null before I even add the KeyValuePair<int, float> of (1, 4.3f), so I'm sure parameter is not null.

Below are the Rpcs being called:

 [ClientRpc]
 public void RpcSendRList(Dictionary<int, float> _rList)
 {
     if(_rList != null)
         opponentResources = _rList;
     else
         Debug.Log("null dict");
 }

The result in the editor is that it logs "null dict". I have debugged this function by putting a breakpoint in just so I can be sure when reading the _rList parameter that it is null and indeed the result is null.

If I have logged the value before as to not be null then why is it being received as null by the client?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by n1gth · Jul 15, 2015 at 11:18 AM

You can only send certain simple types through remote calls (Commands, ClientRpcs). These include int, long, float, Vector3, Color... but do not include complex types like Dictionaries.

Comment
Add comment · Show 2 · Share
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
avatar image Dudledok · Jul 15, 2015 at 11:28 AM 0
Share

I think I remember this from the legacy system and I guess I hoped it had changed in the back of my head. This really should be stated on the documentation! http://docs.unity3d.com/$$anonymous$$anual/UNetActions.html

avatar image meat5000 ♦ · Jul 15, 2015 at 12:16 PM 0
Share

But there is this. I have not tried implementing it though.

http://docs.unity3d.com/ScriptReference/Networking.SyncList_1.html

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

23 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

Related Questions

Multiple Cars not working 1 Answer

Change variable on all players with UNet 1 Answer

Rpc is received by client but Cmd is not received by server 2 Answers

Distribute terrain in zones 3 Answers

[Solved]Networking - Null Reference Exception 2 Answers


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