Unity Networking: how to sync animation with child object?

I am doing multiplayer but I am stuck with animation timing. The current player hierarchy is as follows:

enter image description here

The problem is that the Marine is using IK to aim up / down, which means I am using the OnAnimatorIK feature. To use OnAnimatorIK, the Animator component must be attached to the same game object as a script using OnAnimationIK. This means that I have to attach the animator to the marine game object. If I do this, everything will be fine (if not trying to connect to the network).

Now, if I attach the Network Animator to the Player object , the animation will not update remotely. When I try to connect a Network Animator to a Marine object , the Network ID component is automatically added and cannot be removed. If I try to build a Network Identity component attached to a Marine object, I get the error "You can only have one network ID, and it must be attached to the root object." This means that I have to move my Animator component as well as the PlayerIKHandler script into the Player object to get rid of the duplicated Network Identity component.

If I move the Animator component onto the Player object, it breaks my animations (model stands in T-pose) and I don't see any animation even locally.

It is clear that I am doing something wrong, I just don’t know why. How can I synchronize animation with an animator on a child OR how can I animate a model if the animator component is attached to the Player (just a dummy capsule with scripts on it).

+3


source to share





All Articles