Morph Target replication for Facial Animations

I couldn’t find anything specific to this, and I might be missing something entirely but here is my situation…

I have software that tracks your facial motion, and a plugin into UE4. The software streams in a set of values which are used to set the values of Morph Targets, this gives my in game characters facial animation.

The trouble is, in a multiplayer situation I don’t have the slightest idea how to have every client connected see the facial animations of all the other clients. Does that make sense?

I think boiling the problem down is that I need to get the value of the morph target from the client, and broadcast that value to all other clients so that each client sees the animation.

Have I explained this properly? I’ve tried a series of things, and with some solutions the server can see the client’s animation, but the client can not see the servers, and never can client 1 see client 2’s animations.

Any thoughts?

1 Like

Make the morph target variables replicated . Then get the client to set his own variable so that it’s instant in case of lag . Then get the server to also set the value of the same variables by using a run on server custom event . You might also have to multicast this variable in order to replicate the animations to all clients

I think that Player State blueprint is best place to store and replicate variables in. It is lightweight and replicable copy of player controller. I had similar problem (from replicating and multiplayer POV) while i was making chat system. I found out that only Player State is replicated and copied to all clients. For eg. player controller exists only on server and single client (one owned by actual player).

So you need to send your animation events trough player state. This is how i did my chat communication (modified for anims):

  • first player controller (or AI controller) fires RPC event that triggers animation. It is simple “execute on server”, best place for that event is Game State (it is easy to get reference to on clients, it is also replicated).
  • then Game State on server fires multicast event telling each Player State that one of their players want to play facial animation.
  • last part is finishing the loop. Player States tell back to Player Controller that it should fire that facial animation. Difference now is that each animation is local to just that client and replicated to all other clients

Yes it is weird loop, looks strange in code but without it you will not get that event replicated to all clients. There is also one optimization that you can do, fire anim event on local player controller without all that loop. Then skip that same replicated event, they all come back to your local client in time that is twice the ping, so sometimes delay in animation can be spotted.

And one more tip about multiplayer: make solid system to determine which player is which client. When spawning Player Controllers you need to give them unique IDs (i did it by incrementing integer for each spawned player). Its is either me who cannot get unreal built in player indexes to work or there is some mess in default multiplayer spawning code.

Great, Thanks guys I’m going to look at some of these solutions.