Unet's documentation is lacking, as we all know.
I would love to get this answered, and hopefully it can help others searching later.
Here is what I am trying to do:
- Detect hit with raycast on player client.
- Indicate the hit to the dedicated server using a [Command]
- Notify the one client that was hit using [TargetRPC]
The issue is that the TargetRPC requires a NetworkConnection value, but the only documented way is by using ConnectToClient from that object - which I don't have and I need to get.
How do I identify the Player I hit on the client side to the server in a way that can translate into a proper NetworkConnection value.
On the local player authority object:
CmdIHitSomeone(unknown);
[Command]
void CmdIHitSomeone(NetworkConnect unknown) {
TargetLetYourVictimFeelIt(unknown);
}
[TargetRPC]
void TargetLetYourVictimFeelIt(NetworkConnection unknown){
//do something bad here
}