fpwong
June 12, 2015, 2:38pm
1
Hi, I’ve been testing multiplayer but I’m stuck on syncing the animation.
I want to sync an attack animation that triggers on pressing the A key.
So all I want to do is call an animation on all clients connected as well as the server.
The issue I have is that the command calls it only on server side and not on any clients.
Do I have to do an RPC call inside the Command or something?
void UpdateInput()
{
if (Input.GetKeyDown(KeyCode.A))
{
CmdDoAttack();
}
}
[Command]
void CmdDoAttack()
{
_anim.SetTrigger("Kick");
}
seanr
June 12, 2015, 3:00pm
2
yes you could do it like:
void UpdateInput()
{
if (Input.GetKeyDown(KeyCode.A))
{
CmdDoAttack();
}
}
[Command]
void CmdDoAttack()
{
// check if player can attack
if (isDead)
return;
RpcAttack();
}
[ClientRpc]
void RpcAttack()
{
_anim.SetTrigger("Kick");
}
1 Like
fpwong
June 12, 2015, 3:10pm
3
Thanks seanr, that worked but it wasn’t calling it on the server side - had to make a small change.
I feel like they should have a way to send to the server + all clients instead of doing this but I guess this is not too bad.
[Command]
void CmdDoAttack()
{
if (isDead) return;
_anim.SetTrigger("Kick");
RpcDoAttack();
}
seanr
June 12, 2015, 3:39pm
4
ClientRpc calls are supposed to be called on the host. That is bug:
That is fixed in 5.1p1. You have the right workaround for now.
IsSyncEvent supposed to not fire on a local host for networked scene objects?
seanr
June 12, 2015, 7:06pm
6
it is supposed to fire on the host also.
From what I can tell, even on 5.1.0p1 ClientRpc and SyncEvent aren’t calling on a local host for networked scene objects.