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.
( both in my FPSCharacter.h file, first under public, second one protected)
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.
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:
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.