Hi guys so for a long time i have really struggled with the idea of multiplayer replication especially when it comes to animations. I know a lot of people struggle with this issue too so i thought i would share my methods. I had originally set up my animations using Blendspaces as they are simple and easy to use. After a while though i found them to be more limiting and restrictive and so i began experimenting with locomotion state machines. Luckily for me the unreal system isnt that different from the unity system and so i was able to get a decent system up and running with a little trial and error. anyway here ill talk you through it
so first i wanted to know when the player is moving forward/Backward, Left/right or a combination of both. I tried multiple ways to do this using all the different methods suggested on various forum posts such as using the players velocity, direction, axis input etc in the end i went for this setup for ease of use and flexibility.
so what i did was first create action mappings for each movment in the projects input settings like so.
so obviously you can see that when i press W i will be moving forward. S key moving backward, A key moving left and D key moving right. Normal game WASD controls.
then in my character BP i then checked these player inputs to see which one the player was pressing.
I then created a custom event in order to use these inputs as shown here
so for each custom event all i did was give them a name similar to the action inputs. I then made each event set a boolean value that will drive my animation blueprint.
so for each boolean i made them into a repnotify and inside each repnotify function i simply casted to the animation blueprint and set the boolean to be the same as the booleans inside the animation bp.
so here is the repnotify function for moving forward
as you can see whenever the boolean changes, the repnotify function is called and it simply sends the boolean value into the animation blueprint
inside my animation blueprint i simply have the booleans the same as in my character bp i just added ABP suffix on the end so that i can see that these booleans are from the animation blueprint.
And lastly i use these replicated booleans driven by my player input in order to drive my locomotion animation state machine
so for example here is the transition rule for when the player can move from idle into walk forward. as you can see i simply use the replicated boolean . it is really simple .
so the execution goes like this. player presses W on the keyboard >>>>> this calls the server RPC PlayerIsMovingForward custom event (run on server) >>>>>> this sets the boolean playerIsMovingForward inside the character blueprint to be equal to true. >>>>>>this variable is repnotified so it calls the repnotify function>>>>>> inside this function it casts to the animation blueprint and sets the variable playerIsMovingForwardABP to be equal to true>>>> once the boolean is set to true this causes the player to go into the walking forward animation inside the locomotion state.
here is a small video of the final result . first few mins is set as a dedicated server showing two clients. the second half of the video is set to listen server showing server and one client connected.
as you can see the animations still work and are replicated wether it is a dedicated server or not
if anyone wants any help with replication or setting up a system like this drop me a pm and ill try to help when i can