- Home /
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.
Is photonView the NetworkView component of the game object containing this script ?
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!
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).
Appearntly it didnt change anything, I'm using photon by the way.
It didn't change anything, so the same error is displayed ?
yep.. Same error. I guess it works alittle different with photon.
Did you attach a photon view to the target ? The error message is quite explicite...
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.