{
if(!IsOwner)
{
return;
}
if(!isPunching)
{
punchAnim.Play("Punch");
isPunching = true;
PunchRpc();
hitCollider.enabled = true;
StartCoroutine(PunchCooldown());
}
}
[Rpc(SendTo.Everyone)]
public void PunchRpc()
{
if (IsOwner) return;
Debug.Log("punching");
Punch();
}```
#My rpc call isn't working to get my other players to see i'm punching
1 messages · Page 1 of 1 (latest)
What code runs punchrpc?
Does that debug ever run?
That animation code will never run cuz you return if they are host and aren’t host
{
if(!IsOwner)
{
PunchRpc();
return;
}
if(!isPunching)
{
punchAnim.Play("Punch");
isPunching = true;
hitCollider.enabled = true;
StartCoroutine(PunchCooldown());
}
}
[Rpc(SendTo.Everyone)]
public void PunchRpc()
{
if (IsOwner) return;
Punch();
}```
ive changed it to this and it works however it causes the game to freeze
What code runs punchrpc
at the top of the function
Whats punchcooldown
oh wait im causing recursion
like a lot of it
i think thats the word
im telling all other clients
to run punch on the other client
which then causes them to run the rpc
and then punch
over and over
i need to seperate the trigger from the request
public void TriggerPunch()
{
if (!IsOwner || !isPunching) return;
Punch();
PunchRpc();
}
public void Punch()
{
punchAnim.Play("Punch");
isPunching = true;
hitCollider.enabled = true;
StartCoroutine(PunchCooldown());
}
[Rpc(SendTo.Everyone)]
public void PunchRpc()
{
if (IsOwner) return;
Punch();
}
private IEnumerator PunchCooldown()
{
yield return new WaitForSecondsRealtime(0.5f);
hitCollider.enabled = false;
isPunching = false;
}```
for some reason its now casuing all players to punch when one player punches
yeah on the client that punched every player punches but on other clients no one is punching