- Home /
How to send player reference over network
I'm using the new Networking system introduced in Unity 5.
In my game, I need chat notifications about who killed who but this this code generates an error saying that I can't send Components over network.
[ClientRpc]
public void Rpc_KillNotification(Character killer, Character victim){
Debug.Log(killer.name + " killed " + victim.name);
}
Most probably what I have to do is to send player ID but I don't know where to get it or just send NetworkIdentity? Since I have another question too, I didn't want to experiment.
So my questions are:
How can I send a reference about a networked object passed as an argument in a Rpc function, and:
How can I call a procedure only on a single client
Answer by seanr · Jan 11, 2016 at 03:54 PM
send the GameObject, or the netId and look it up with NetworkServer.FindLocalObject or ClientScene.FindLocalObject.
ClientRpc goes to all clients. You can send messages to individual clients, but not ClientRpcs.
Your answer
Follow this Question
Related Questions
When the spawned object is ready to send RPC? 0 Answers
How do you store variables on server? 0 Answers
Animation over network using rpcs 0 Answers
UNET Rpc calls wrong inherited script 2 Answers