- Home /
Question by
Sneirox · Mar 12 at 11:16 AM ·
client-server
[Netcode] How to get client Id inside ServerRpc method which called this ServerRpc method?
[ServerRpc(RequireOwnership = false)]
public void SomeServerRpc()
{
// Get Client ID here
}
Comment
Best Answer
Answer by J7 · Mar 14 at 06:17 PM
I don't think that you can get the client Id from a "context" or whatever, so simply pass it as parameter.
[ServerRpc(RequireOwnership = false)]
public void SomeServerRpc(ulong clientId)
{
}
And use it this way
public void SomeActionOnClient()
{
networkObject.SomeServerRpc(NetworkManager.Singleton.LocalClientId);
}
This is also the way the Boss Room example does it, you can download it here: https://unity.com/de/demos/small-scale-coop-sample
Your answer

Follow this Question
Related Questions
Detect if compiling from Unity project 3 Answers
UNET Server and Client business classes 1 Answer
Problem numbering Clients 0 Answers
ClientRpc sent but not received 0 Answers
UNet | I'm having trouble assigning authority to game objects 0 Answers