Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Win3xploder · Dec 02, 2014 at 01:10 PM · networknullparameter

RPC call: parameter suddenly null

Hi guys i have this werid bug where a int parameter passed to an RPC suddenly becomes null. The error message looks like this:

 Sending RPC failed because 'UpdateCallbackVariablesUnit' parameter 7 was null
 UnityEngine.NetworkView:RPC(String, NetworkPlayer, Object[])
 MouseFeedbackControl:UpdateTopSelectedUnit(NetworkPlayer, Int32) (at Assets/Scripts/MouseFeedbackControl.cs:307)

The RPC is called by this line in OnGUI() in the client:

 networkView.RPC ("UpdateTopSelectedUnit", RPCMode.Server, Network.player, 0);

And here is the code containing the error. The function is supposed to sync the client to the server (authoritative server):

 [RPC] public void UpdateTopSelectedUnit(NetworkPlayer player, int index) 
     {
     
         int spellcasttype = 0;
         int spellID = 0;
         int buildID = 0;
         string spellname = null;
         string buildname = null;
         
         // PLAYER 1
         if(player.ToString() == "1")
         {
             
             if(selectedUnits1.Count > 0)
             {
                 topSelectedUnit1 = selectedUnits1[0] as GameObject;
                 
                 if(topSelectedUnit1.GetComponent<Unit>().UnitSpells.Count > 0)
                     {
                     spellID = (int)topSelectedUnit1.GetComponent<Unit>().UnitSpells[index];
                     spellname = topSelectedUnit1.GetComponent<Unit>().UnitSpellNames[index] as string;
                     spellcasttype = (int)topSelectedUnit1.GetComponent<Unit>().UnitSpellCastType[index];
                     }
                     
                 if(topSelectedUnit1.GetComponent<Unit>().UnitKnowArray.Count > 0)
                     {
                     buildID = (int)topSelectedUnit1.GetComponent<Unit>().UnitKnowArray[index];
                     buildname = topSelectedUnit1.GetComponent<Unit>().UnitKnowNamesArray[index] as string;
                     }
 //error is in the following line
                 networkView.RPC("UpdateCallbackVariablesUnit", player, player, 
                                      topSelectedUnit1 != null, 
                                      !topSelectedUnit1.GetComponent<Unit>().isStationary,
                                      topSelectedUnit1.GetComponent<Unit>().unitHasAttack,
                                      topSelectedUnit1.GetComponent<Unit>().isBarracks,
                                      spellcasttype,
                                      spellID,
                                         spellname,
                                        buildID,
                                        buildname,
                                       topSelectedUnit1.GetComponent<Unit>().UnitSpells.Count,
                                         topSelectedUnit1.GetComponent<Unit>().UnitKnowArray.Count);
             }
             else 
                 topSelectedUnit1 =  null;
         }
 }

I can't see where the mistake is, please help.

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
0

Answer by Win3xploder · Dec 04, 2014 at 05:59 PM

Solved: since spellname and buildname aren't always changed from their initial value null, they were sometimes sent with the RPC as null, causing the error.

Comment
Add comment · 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

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

2 People are following this question.

avatar image avatar image

Related Questions

NullReferenceException - With Network PlayerSpawn 0 Answers

Networking 8 CCU used constantly - Increments 4 for each player connected. 2 Answers

Instantiate prefab and passing parameter 1 Answer

WebGL - ArgumentNullException: Parameter name: c/s 0 Answers

RPC , string parameter is sent, but length is 0 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