• 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 benk0913 · Jun 08, 2013 at 06:08 PM · errornetworkphotonrpcargument

Photon RPC problem...

ive got this error: PhotonView with ID 5001 has no method "EquipItemShared" that takes 1 argument(s): String

That is my script:

 if(GUILayout.Button ("Equip"))
                                     {
                             
                                         //Load the item.
                                         
                                         callEquipItem(PhotonTargets.Others,lastitemPressed.GetComponent<I_info>().itemName);
                                         
                                         if(photonView.isMine)
                                         equipItem(lastitemPressed.GetComponent<I_info>().itemName);
                                         
 }
 
 
 _________________________________________________________
 
 
 
     void equipItem(string itemNameShared)
 
     {
         //Will quip the selected item.
         GameObject weaponUsed=PhotonNetwork.Instantiate(itemNameShared,GetComponent<P_combat>().handBone.transform.position,GetComponent<P_combat>().handBone.transform.rotation,0);
         weaponUsed.transform.parent=GetComponent<P_combat>().handBone.transform;
         GetComponent<P_combat>().equippedWeapon=weaponUsed;
     }
     
     [RPC]
     
     void EquipItemShared(PhotonMessageInfo info, string NameShared)
     {
         if(info.sender.ID != PhotonNetwork.player.ID)
         {//Will show item equipment for other players.
         equipItem(NameShared);
         }   
     }
 
     
 
     void callEquipItem(PhotonTargets target,string itemNameShared)
     {//Will call "Fire" for the given targets.
         photonView.RPC("EquipItemShared",target,itemNameShared);
     }

It happends when I press the equip button as you see.

Comment
Add comment · Show 2
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 KiraSensei · Jun 08, 2013 at 06:21 PM 0
Share

Is photonView the NetworkView component of the game object containing this script ?

avatar image benk0913 · Jun 09, 2013 at 02:18 AM 0
Share

No, a different script, why?

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by drod7425 · Nov 04, 2013 at 08:57 PM

Photon RPCs can take a PhotonMessageInfo parameter as the last parameter in the method. You have it as the first. Try switching your parameters around and take a look at this:

http://doc.exitgames.com/photon-cloud/PUNOverview/

Have a good day!

Comment
Add comment · Show 1 · 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 shieldgenerator7 · Feb 04 at 09:00 AM 0
Share

This link is broken

avatar image
0

Answer by KiraSensei · Jun 09, 2013 at 08:17 AM

RPC is a method you call from a network view, not a script.

You need to attach a network view component to the game object containing the script.

Have a look at the documentation.

Your target needs a network view too, with this script attached too (it needs to know the "EquipItemShared" method too).

Comment
Add comment · Show 6 · 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 benk0913 · Jun 09, 2013 at 10:54 AM 0
Share

Appearntly it didnt change anything, I'm using photon by the way.

avatar image KiraSensei · Jun 09, 2013 at 10:59 AM 0
Share

It didn't change anything, so the same error is displayed ?

avatar image benk0913 · Jun 09, 2013 at 11:22 AM 0
Share

yep.. Same error. I guess it works alittle different with photon.

avatar image KiraSensei · Jun 09, 2013 at 11:43 AM 0
Share

Did you attach a photon view to the target ? The error message is quite explicite...

avatar image benk0913 · Jun 09, 2013 at 03:31 PM 0
Share

Yep. I did.

Show more comments
avatar image
0

Answer by vfxjex · Jun 02, 2014 at 08:58 AM

try PhotonPlayer targetPlayer instead of PhotonTargets target. i don't know but I used this in mine and it works.

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

18 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

Related Questions

Photon RPC "DestroyRpc" function not found 1 Answer

RPC Acting strangly 1 Answer

RPC Player Name and show it above head 0 Answers

RPC calls client to server Errors 1 Answer

Photon Networking: RPC call doesn't work over other clients 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