Skip to content

NetworkAnimator dont synchronize animator layer weigth #2381

Closed
@StopFlaming

Description

@StopFlaming

Description

The NetworkAnimator dont send animator layer weight updates. Its not possible from host to client or from client (sServerAuthoritative = false) to host.
If i have 2 Players (Host and Client) i try to override the current animation (just the arms). If i do it with animation layer i have to set the correct layer weight. But the attached Component doesnt sync the weight value updates. The will just set on the owner.

The Component

public class OwnerNetworkAnimator : NetworkAnimator
{
    protected override bool OnIsServerAuthoritative()
    {
        return false;
    }
}

Code Example to set the weight

// Works Great on host and client
animator.SetFloat("vectorX", currentAnimationVector.x);
animator.SetFloat("vectorY", currentAnimationVector.y);

// Work just for the owner
// Set AnimationLayer
animator.SetLayerWeight(1, (controller.Enemy ? 1 : 0));

Actual Outcome

animator.GetLayerWeight(1) is always 0 and will not be updated for non owner.

Expected Outcome

animator.GetLayerWeight(1) will be updated for owner and for non owner

Screenshots

Unbenannt-1

Environment

  • OS: Windows 10
  • Unity Version: 2021.3.16f
  • Netcode Commit: 1.1.0

Additional Context

Because of the problem, wrong animation will be executed.

WORKAROUND:
In my case i have to layers. the seconde one overrides my arm animations. Because i cant change the layer weight over the network, i set the 2. layer weight (arm layer) to 1 (full activated) and leave it like this the whole time. In the seconde layer i created an empty state (that doesnt change anything) and a arm animation state. Now, with the network animator i can send a trigger (important: trigger have to call over the network animation component) to start the arm animation.

With this workaround, everything works for my simple example.

Metadata

Metadata

Labels

priority:highThis issue has high priority and we are focusing to resolve itstat:importedStatus - Issue is tracked internally at Unitytype:bugBug Report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions