Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 UnityNoob123 · Oct 22, 2017 at 03:19 AM · networkingrpc

Unet RPC call not working on clients

Thanks for checking out my question, I want to activate a third person gun on my player object when the player equips a first person gun. I called an Rpc when the player adds their first person gun to the weapon slot, and then the function searches through the third person gun array looking for the same name, then it enables the correct one. This seems to only work on the host, and not the client. I am not sure what it is I am doing wrong, I read something about not passing arguments to Rpc calls, so I made a global string variable that gets set to the correct gun name before the Rpc is called. Then in the Rpc call it uses that already set global variable, but it still only works for the host. Any help is appreciated, thanks.
PS. I use getcomponent().thirdPersonWeapons because on start up it sets the weapons to a different layer that only other clients can see, so instead of making another array with the exact same gameobjects, I just borrowed the one from the player controller script.

 void EnableWeapons () {
         if (weaponSlector == 1) {
             if (rifle1GO != null) {
                 rifle1GO.SetActive (true);
                 weaponName = rifle1GO.name;
                 RpcEnableThirdPersonWeapon ();
             }
             if (rifle2GO != null) {
                 rifle2GO.SetActive (false);
             }
         }
 }
 
 [ClientRpc]
     void RpcEnableThirdPersonWeapon () {
         for (int i = 0; i < GetComponent<playerController>().thirdPersonWeapons.Length; i++) {
             if ( GetComponent<playerController>().thirdPersonWeapons [i].name == weaponName) {
                 GetComponent<playerController>().thirdPersonWeapons [i].SetActive (true);
             } else {
                 GetComponent<playerController>().thirdPersonWeapons [i].SetActive (false);
             }
         }
     }
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

104 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

Related Questions

Networking pattern for team-based play 1 Answer

RPC isn't called on objects with another name, even though they have the same script. 1 Answer

View ID AllocatedID: # not found during lookup. Strange behaviour may occur 1 Answer

How to use an RPC to send an animation over the network? 2 Answers

Whats wrong with my RPC,!showing clothes on the network 0 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