Received RPCs have different paramaters than sender, wat.

Options
Hi all,

So I have simple gun stuff that ejects casings, sends tracers, and shows a flash. Each of these has a PhotonView and it works fine on the client end. However, when sending something like:
public void CreateMuzzleFlash(Transform gun, Vector3 muzzlePosition)
{
pView.RPC("SpawnNetworkFlash", PhotonTargets.All, muzzlePosition, gun);
}

[RPC]
void SpawnNetworkFlash(Vector3 spawnPoint, Transform gun)
{
// blah blah blah
}

I get the following error:

PhotonView with ID 2001 has no method "SpawnNetworkFlash" that takes 2 argument(s): Vector3, Vector3[]

It also happens with another RPC call that sends a Transform, Vector3, and string; it complains of receiving a Vector3[], Vector3, string.

I had no idea what to search, and didn't find anything related, anyone know what the balls is going on? Thanks!

Comments

  • Tobias
    Options
    Ah, sorry. That's a problem, cause we can't actually send Transforms!
    Unity's api keeps us from instantiating a Transform, so the reading side has no way to read a sent Transform into anything.

    Instead, use individual Vector3 for pos and rotation. The RPC method must be adjusted accordingly.

    Even better: You don't have to send the Transform as you do in this case. The gun you reference has a PhotonView which has an ID. If you use that gun's PhotonView to call an RPC on, it will only trigger on that gun. No need to pass the Transform (a common way to identify/pass objects).
  • Befall
    Options
    Ah cool, thanks for the info! And I can't actually do that in THIS case, since there are local models and 3rd person models depending on who's where, so they wouldn't match up. But I didn't end up needing most everything on the Transform, so I'll just send a Vector3 or something!