Problem is not reproducible or outdated
UNet - Sync more than 32 parameters with "NetworkAnimator"
I have a "NetworkAnimator" component attached to my player but it has the following error:
NetworkAnimator can only select between the first 32 parameters in a mecanim controller.
I have more than 32 parameters in the mecanim controller. So MOST of the animations are synced up. So is there a way to make the NetworkAnimator component sync ALL parameters instead of just 32? Am I stuck with coming up with a solution of my own?
If I have to come up with a solution of my own is there a way I can dynamically collect the parameters from a target animator component and sync that across the network? I really don't want to have to write all of the parameters by hand as a [SyncVar]
.
So I can't send a list over the network... sad... Here is what I am trying to do. If someone has a better way I am definitely all ears (This doesn't work because of my generic list):
public class $$anonymous$$_AnimSync
{
public string name = "";
public string value = "";
public AnimatorControllerParameterType type = AnimatorControllerParameterType.Bool;
}
...
...
private void Update()
{
if (isLocalPlayer == true)
{
BuildAnimList();
}
}
void BuildAnimList()
{
for (int i = 0; i < animator.parameters.Length; i++)
{
$$anonymous$$_AnimSync new_param = new $$anonymous$$_AnimSync();
new_param.name = animator.parameters[i].name;
new_param.type = animator.parameters[i].type;
switch(animator.parameters[i].type)
{
case AnimatorControllerParameterType.Bool:
new_param.value = animator.GetBool(animator.parameters[i].name).ToString();
break;
case AnimatorControllerParameterType.Float:
new_param.value = animator.GetFloat(animator.parameters[i].name).ToString();
break;
case AnimatorControllerParameterType.Int:
new_param.value = animator.GetInteger(animator.parameters[i].name).ToString();
break;
}
anim_params.Add(new_param);
}
}
[Client]
void TransmitPlayerAnimations()
{
if (isLocalPlayer == true)
{
Cmd_RecievePlayerAnimations(anim_params);
}
}
[Command]
void Cmd_RecievePlayerAnimations(List<$$anonymous$$_AnimSync> recieved_anims)
{
Rpc_SyncAnimations(recieved_anims);
}
[ClientRpc]
void Rpc_SyncAnimations(List<$$anonymous$$_AnimSync> recieved_anims)
{
foreach ($$anonymous$$_AnimSync item in recieved_anims)
{
switch (item.type)
{
case AnimatorControllerParameterType.Bool:
animator.SetBool(item.name, bool.Parse(item.value));
break;
case AnimatorControllerParameterType.Float:
animator.SetFloat(item.name, float.Parse(item.value));
break;
case AnimatorControllerParameterType.Int:
animator.SetInteger(item.name, int.Parse(item.value));
break;
}
}
}
$$anonymous$$y only other thought would be to JSON serialize and send to server. Then deserialize on the client and apply the animation parameters.