How does animation replication work?

Simple question, when an animation is played on a source client, fired to the server, and the server tells all clients that the source client is playing that animation, do the clients that receive that message

  1. sync up that animation so that even if there is network latency, they will be on the same keyframe as the source client
    or
  2. start playing that animation from the beginning

What kind of animation replication are you talking about, replication via the Animator object or manual replication through remotes? Not exactly clear.

Both points are applicable in the world of animation replication. Point 1 applies to replication through the Animator object, just there isn’t any syncing because the client is authoritative of playback and replication of an animation. Point 2 is applicable for replication through remotes. You won’t ever need to manually replicate animations unless you modify the Animator though.

So basically it works both ways, just depends on what the circumstances are.

1 Like

Both ways suffers the latency of server lag.

There is no way to immediately communicate these replications to other clients in a way that they will be on the same key frame garaunteed.

Sorry for the confusion, I meant playing animations through the Animator object.

So the Animator object automatically syncs up animations? I’m looking to make animations that depend on certain keyframes being triggered in the animation, so I need other clients to be able to listen to another client’s animations from the beginning (for example, if an animation requires the instantiation of a game object, and later keyframes or even the animation depend on that game object being instantiated).

The Animator wouldn’t have to do any syncing if it’s giving the source client authority over playback of animations.

In terms of your use case, it would definitely be something to try out with a quick test. Play an animation from one client and have another try to listen to when it reaches certain keyframes or markers. I am certain about the playback behaviour but not so much if another client is capable of listening for reached signals on the track.

1 Like

Oh, I think I was mistaken. I thought the Animator object simply passed something like the ID of the animation to the server, and the server passed the ID of the animation over to the other clients and let the other clients handle playing the animation, instead of the source client passing each Motor6D Transform.

It would be pretty painful if the workflow was like that. :sweat_smile: Thankfully, that kind of transfer doesn’t occur.

LoadAnimation will parse animation data from an Animation object given a valid id. That data is then cached in the entity that loaded the animation. From there, the Animator handles the rest.

The server’s only involvement should be creating the Animator object if one doesn’t exist and then passing replication control to the client, much like SetNetworkOwner for BaseParts and character physics replication. After that, it’s all the client for playing animations.

Checking for reached keyframes should work, but it’s definitely worth a test round to confirm.

1 Like

Ah, alright. Thanks for the info. Setting up a test right now.

If you can’t wait for the key frame (if your test fails), you can also send a remote event from the players client once the key frame is reached, to the rest of the players clients, which should have a negligible difference to the delay you would already face from having other players wait for that key frame after that animation had been replicated.

2 Likes

Actually, I think this is what I’m going to do. Thanks!

1 Like

You are welcome! Let me know if you have any difficulties.

I just tested it with the Network Simulator option on at around 52ms I think, and it worked fine.

1 Like