- Home /
Question by
maxstinkyfoot · Nov 15, 2021 at 03:53 AM ·
c#networkingmirror
Rpc client not functioning as expected (Mirror networking)
Hi, I made this script, and it was working a few days ago, but now, for some reason it just pushes the rigidbody(player) slightly and then glitches out on the other player's screen, moving the rigidbody(player) back and forth. Please help, here's my code:
if (Input.GetButtonDown("Fire1"))
{
CmdKick();
}
[Command]
void CmdKick()
{
RpcKickSendServer(500);
}
[ClientRpc]
void RpcKickSendServer(float kickStrength)
{
RaycastHit hit;
if (Physics.Raycast(playerCamera.transform.position, playerCamera.transform.forward, out hit, 3))
{
if (hit.rigidbody != null)
{
hit.rigidbody.AddForceAtPosition(playerCamera.transform.forward * kickStrength, hit.point, ForceMode.Impulse);
Debug.Log("I hit somebody");
}
}
}
thank you in advance!
Comment