Download

why is animation replication so hard

Hi,

yesterday, I started my first multiplayer project (also my first major c++ project.). Today I wanted to try and add some animations (pre-made, AKA I stole them all from a video game with a special file viewer.) I already know the basics of a state machine blueprint, so I made one of those and tried to sync it with some c++ code. I got it working for when a client sees itself (I’m going to remove the ability to see itself anyway so that doesn’t help much), but when other clients look at it, they just see the Idle animation. Now this was really interesting to me, because if I saw that one client couldn’t see another’s attacking animation, I would expect it not to see any of the client’s animation, but the Idle one showed anyway.

Anyway, I wanted the animation to replicate to all clients. Remember I’m pretty new at this stuff, plus I’m 14. I looked up some tutorials but they all would have required me to rework my code or looked super complicated. I don’t really feel like this should be that complicated, considering that if you can get Player 2 to move on Player 1’s screen, you should probably be able to get the bones moving pretty easily as well. I would really appreciate any help or advice.

I also forgot to mention, I know all the animations work from a separate project, so it’s not like a problem with the animations.

Note that the “movement mode” when replicating may be “networked” rather than “walking” or whatever, if you’re using the built-in Character controller.

In general, replication is no harder than normal controls, as long as the normal controls go through the player controller. The controlled Pawn then combines the observed movement/velocity of the pawn, as well as whatever states are set on it by the player controller (those states need to be made replicated!) and plays back the animations.

As long as your pawn/controller separation is clean, and your “state” properties are well replicated, and your blueprint is cleanly using only the state observable by a replicated pawn, it should Just Work ™ (although either it will be delayed a bit, or it will be based on extrapolated state, because network always has a delay.)

Also, after the buff, Void Rays are awesome early to middle game units!

when other people use them, they counter stalkers. When I use them, stalkers counter voids. So I hate using void rays (plus I’m not scum of the earth and I would rather go for a charge allin)

Honestly, I have no clue what I’m doing. I’ll just show you what I have.
@jwatte
b888c8f6abea2e1104b5c4e553454935ab6e6619.png
95bcdbe9e05a11a0cebe96a28a37135d0bb67192.png
( both in my FPSCharacter.h file, first under public, second one protected)

3b2de88a0b6d23928e445ccce8001e52d3b6024e.png

4bc3b64121813b0553a3f7626adf2776195179f8.png

in the firstperson character.cpp file. Yes I know printtak is s stupid name, it’s just the function for changing the variable back to false.
https://forums.unrealengine.com/core/image/gif;base64
​​​

05ba070b7885cc746b14ad63352ccc711ee7719c.png

that’s the animation blueprint. For some reason the cast kept failing, but the animation worked for the client itself anyway?

And finally I have a state machine but that doesn’t really matter, That’s just where I use the variable.

The thing I find interesting is that I can see other clients playing the Idle animation:

761e4e13cb461e8f873c4d073e14d215a07baa49.png

And the client can see itself playing Attacking, but other clients don’t. Thanks!

What pawn class have you configured for the replicated pawn? If you print the class of the pawn you DO get, (that fails the cast,) what does it print?

@jwatte surprisingly, no matter which client I do it on, it only prints out the name of one. (and it only prints the name of the anim… so marine_anim_C_1)

Just a line of thought.

What is being replicated is not the animation but the current state of the movement component. In-place animation is reactive, unlike root motion, so what the client gets is the state change update which then the animation on their end is played via their version of the animation BP. Check out the 3rd person template. It has functions in the character controller that ties the input into the movement component and in your animation blueprint you cast to the movement component for the stat change on your end.

Done this way the MC will then manage the replication requirements for you. So if you pus “W” to move forward on your end, pass it through the MC, cast for the state change of the capsule, is the capsule moving jumping walking ect, then it should replicate both sides of the fence.