- Home /
Problem with PhotonView.RPC
I use this to run the RPC
photonView.RPC("Aiming", PhotonTargets.All, 0);
But I get the error: PhotonView has no method "Aiming" that takes 1 arguments: Int32
And this is the RPC:
[PunRPC]
IEnumerator Aiming()
{
GameObject bulletz = Instantiate(trunk, y.transform.position, y.transform.rotation) as GameObject;
shotsound.Play();
yield return new WaitForSeconds(1);
Destroy(bulletz);
}
Anyone know what the problem is? Thanks
Answer by Runalotski · Nov 25, 2015 at 04:45 PM
I believe the the RPC is
photonView.RPC(RPC, Target, Arguments);
and your RPC Aiming has no arguments so change the rpc call to
photonView.RPC("Aiming", PhotonTargets.All);
and this should work if you want to add arguments as well then you need to add it to the RPC so you could do this for example
photonView.RPC("Aiming", PhotonTargets.All, 5f);
[PunRPC]
IEnumerator Aiming(Float waitTime)
{
GameObject bulletz = Instantiate(trunk, y.transform.position, y.transform.rotation) as GameObject;
shotsound.Play();
//the variable has been added here
yield return new WaitForSeconds(waitTime);
Destroy(bulletz);
}
Your answer
Follow this Question
Related Questions
Photon Network instantiate problem when Master changes 0 Answers
How to connect to our own dedicated server using photon networking in unity?(Self-hosted) 0 Answers
PhotonNetwork Scripted Spawn player 0 Answers
Custom Properties, Unity, Object refence not set to an instance of an object 0 Answers
Multiple Cars not working 1 Answer