x


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.

more ▼

asked Jun 08, 2013 at 06:08 PM

benk0913 gravatar image

benk0913
194 90 82 85

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

Jun 08, 2013 at 06:21 PM KiraSensei

No, a different script, why?

Jun 09, 2013 at 02:18 AM benk0913
(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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!

more ▼

answered Nov 04, 2013 at 08:57 PM

drod7425 gravatar image

drod7425
252 2 5 10

(comments are locked)
10|3000 characters needed characters left

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).

more ▼

answered Jun 09, 2013 at 08:17 AM

KiraSensei gravatar image

KiraSensei
3.4k 93 95 108

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

Jun 09, 2013 at 10:54 AM benk0913

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

Jun 09, 2013 at 10:59 AM KiraSensei

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

Jun 09, 2013 at 11:22 AM benk0913

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

Jun 09, 2013 at 11:43 AM KiraSensei

Yep. I did.

Jun 09, 2013 at 03:31 PM benk0913
(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Jun 02 at 08:58 AM

vfxjex gravatar image

vfxjex
41 1 2

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3634
x1195
x481
x367
x39

asked: Jun 08, 2013 at 06:08 PM

Seen: 2728 times

Last Updated: Jun 02 at 08:58 AM