Download

Rep notify variables not replicating

Ok so basically I have a state machine for my animations that are driven by booleans. So for example when playerIsMovingForward Boolean sets to true the player is moving forward so it transitions into walk forward animation etc. Now this all works fine on server side and client side in single player yet multiplayer and the clients animations are not replicated he simply slides around .

Now I have done print strings and the booleans are being set in my character BP and sent to the animation BP where they are setting booleans of the same name . All is fine so my question is why are the animations not replicating .

The booleans in the character BP are set to rep notify . Inside the rep notify function I simply take the Boolean cast to the anim BP and set the same Boolean to be equal to the same value. It is my understanding rep notify is called both by server and remote machines so why doesn’t it replicate?

My work around has been to ditch rep notify altogether and manually replicate by using custom events . So basically run on server custome event set Boolean, multicast event set Boolean.

Anyone explain why and if rep notify does not replicate then how are you supposed to use it thanks ?

I’m at work at the moment but can post screen shots later

ok so i figured it out. Repnotify was working howether in order for them to replicate succesfully to the client they still have to be called from the server. So now its easy to replicate anything with no need for multicasting as i use repnotify instead. I wonder though if anyone can answer is repnotify more efficient than multicasting??

For anyone wanting to know what i mean 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 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.

55cb27ab85a242e695485a2f2a50707c.png

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

b05e605875c0bf0d893a97508580d926d2d687a8.jpeg

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.

c4d21c80bc98ab59d5abc3440fff132622a9a15e.jpeg

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

9df3ca390c4010439129ef7e3f9f68fb45add1da.png

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.

96089a702420cd107ae4dfa33cbeabcfdeda7736.png

And lastly i use these replicated booleans driven by my player input in order to drive my locomotion animation state machine

851a35706a8c4293b01fefb4ff1fb139.png

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 .

a5bf8085268e4a4eb820f8d4e4c70a67.png

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 odf 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

I had originally had this entire system set up using blendspaces replicated working fine but it is my personal opinion that although blendspaces are amazing and a lot quicker to set up overall using locomotion state machines gives you greater flexibility and control over youre animations and makes it easier to add and exstend them later on .

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

thanks guys