- Home /
Override animation with bone rotation on Mirror Networking
Hi, I've been starting to work with Unity recently and i'm strugling.
Using Mirror Networking, I want the rotation I make on a bone (the head of my player) to show on all other clients.
I can't figure out a way to override (on non-owner clients) the animation brought by the NetworkAnimator. The NetworkTransformChild linked to the head doesn't affect non-owner clients, since the animation seems to go first.
Let's say I start a server+host = client1 that controlls player1, and then I connect a client2 that controlls player2; At the moment, the player2 rotates and client1 shows the rotation (this is the behavior i want), but while player1 rotates, client2 doesn',t show the rotation.
Here is the part of the script i made that handles the bone rotation.
void Update()
{
if(isLocalPlayer)
{
/*some stuff that handles animation*/
}
else
{
saveHeadRotation = head.transform.localEulerAngles;
}
}
void LateUpdate()
{
if (isLocalPlayer)
{
head.transform.localEulerAngles = new Vector3(-cameraController.xRotation, 0, -cameraController.yRotation);
}
else
{
head.transform.localEulerAngles = saveHeadRotation;
}
}
Here i suppose that the update order on non-owner clients is the same as on owner client and follows the "Updates -> Animations -> LateUpdates". To override the animation on non-owner clients, I save the rotation of the bone and reassign it after the animation. Since this doesn't work, i guess there is a problem in the way I think and what I assume of Mirror.
Can anyone help me understand the way Mirror works with animations... and eventually help me fix my problem ?
Thanks a lot.