Hi,
In my multiplayer game when a player shoots a missile I photon instantiate it:
GameObject GO = PhotonNetwork.Instantiate(MissilePrefab.name, muzzle2.position, transform.rotation, 0);
GO.GetComponent<Missile>().myAttacker = gameObject.name;
The second line tells the missile script that the public string “myAttacker” which is in the missile script is named after the sender of the missile.
When the missile hits a player I then want that player to detect that string, or who shot the missile.
So on the missile script - OnCollisionEnter I have this:
if (coll.gameObject.tag == "John")
{
GetComponent<PhotonView>().RPC("NameOfAttacker", PhotonTargets.All, myAttackerF);
}
And the RPC NameOfAttacker looks like this:
[PunRPC]
void NameOfAttacker(Collision coll/*, string attacker*/)
{
DidIDie d = coll.gameObject.GetComponent<DidIDie>();
d.myAttackerD = myAttacker;
}
“DidIDie” script is on the player tagged “John” and has another public string named "myAttackerD " and I was hoping that myAttackerD would be equal to myAttacker but instead I get this error:
PhotonView with ID 1015 has no method “NameOfAttacker” that takes 1 argument(s): String
I’m stuck, does anyone know what I’m doing wrong and how to have the string “myAttackerD” on “john”'s script be the name of the person who fired the missile?