RPC call *sorta* not working...

Ok so I am making a simple networking FPS, and I am trying to detect when a player has been shot, I can figure out who has been shot, but after that nothing is really working…

So I have a script that just does a raycast to figure out if you shot someone, if you did, then it sends out a RPC call, to figure out who has been shot, and to cause a reaction.

This is the RPC call

@RPC
function YourDead(n : NetworkViewID, _name : String) {
	if (n.isMine) {
		chat.networkView.RPC("ApplyGlobalChatText", RPCMode.All, "*************" + PlayerPrefs.GetString("name") + " Has been shot by: " + _name, 1);
		transform.GetComponent(GunController).hasBeenHit = true;
		transform.position = GameObject.FindWithTag("Respawn").transform.position;
		yield WaitForSeconds(3);
		transform.GetComponent(GunController).hasBeenHit = false;
	}
}

It is able to tell who has been shot, and calls the actual code inside the if statement, however the chat.networkView.RPC… is the only thing that really works. Changing the transforms position doesn’t work, and changing the boolean value doesn’t work, anyone know what I am doing wrong?

Anyone know?

Check to make sure that FindWithTag() GetComponent() are returning objects.

Lets see your RPC call of YourDead.

Sorry it took me so long to respond, I did however finally figure it out.

Originally my RPC call was like this

transform.networkView.RPC(“YourDead”, RPCMode.Others, hit.transform.networkView.viewID, tmp);

I figured out though that I needed to change it to

hit.transform.networkView.RPC(“YourDead”, RPCMode.Others, hit.transform.networkView.viewID, tmp); // hit is a RaycastHit.

good to hear that you are up now :slight_smile: