x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Animation replication is not working

Hi I am making a game based off of the multiplayer ue4 youtube tutorial series, My character animations are not replicating correctly i have tried many of the methods on youtube and based on my own understanding tried some things, nothing has worked. Screen shot 6 shows the replication script as well as the settings for my character's replication, Screen shot 7 shows the event graph of my anim blueprint screenshot 8 shows the condition for the animation to be played. I would love if someone could look through the code and help me find this issue.

Product Version: UE 4.20
Tags:
screenshot-6.png (484.1 kB)
screenshot-7.png (698.7 kB)
screenshot-8.png (552.7 kB)
more ▼

asked Mar 25 '19 at 06:24 PM in Blueprint Scripting

avatar image

Glepnizaster
3 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

First off, some general points you should keep in mind:

-If you want the clients to see what the server is doing, the appropriate variables need to be replicated (variables ONLY replicate from Server to Client, not the other way around). One way to do this is what you are trying to do, which is to use a replicated variable that is called on tick from the Anim BP. What you are missing is that you need to set that variable on the server if the clients are calling the code. In other words, the server should simply set the "Dashing" bool, but the clients should run a custom event running on the server, which in turns run a multicast event, which then sets the "Dashing" bool. Alternatively, you can try the method I'm suggesting below using interface calls if you don't need it set on tick.

-If you want the server to see what clients are doing, they need to run the code you want replicated on the server.

-If you want clients to see what other clients are doing, you need to get that code to run on all the connected clients (this is what a multicast would accomplish).

So for example, if all you're needing to do is replicate an animation that's triggered in your Anim BP by a boolean, and you don't need that boolean checked on tick, you could try the following:

  1. Create an interface for your Animation Blueprint.

  2. Create a function in the interface to set the variable you want to replicate (i.e. "Dashing").

  3. Call that function you just created as an event in your Animation BP and use it to set your variable.

  4. In your Character Blueprint, set up a custom event running on the server which in turn runs a custom event running a multicast which sets the variable in the Anim BP using the interface call.

  5. Finally, use a Switch Has Authority to check who's running the code. If it's the server (the authority), you just need to call the multicast event. If it's the client, you need to get the server to run that multicast for you, so call the server event.

I've attached screenshots of a working example I'm using in my own project below, where I'm setting an "Is Taking Cover" variable in my Anim BP so the taking cover animation is replicated to everyone. If you're not interested in this approach, like I said in the first paragraph, it's very simple to just replicate the variable and set it in your Anim BP tick event. Just make sure clients are setting that variable on the server.

AnimBP Interface: AnimBP Interface

Interface call in Anim BP: Interface Calls

Custom Events in Player Character: Custom Events

Switch Has Authority check: Switch Has Auth

more ▼

answered Mar 27 '19 at 05:56 AM

avatar image

Drgy55
39 5 10 14

avatar image Glepnizaster Mar 27 '19 at 02:23 PM

@Drgy55 Thankyou this method worked this has been annoying me for a week and it is finally solved

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

It looks like you flipped the names on your RPCs, and while that's confusing, it isn't what's breaking your code.

"Switch has Authority" is a node that checks to see if the object running the code is on the server or on the client. In most multiplayer games, the server must have authority to prevent cheating. What that means is that the game code should run on the server and the client should have no say whether the code works or not. All the client does is sends requests to the server, then the server says "hey, can he do that or is there a restriction that prevents it?" and if it's ok, the server does the code and the player gets the update after it runs on the server.

"Run on Server" sends the command to the server from the client and runs it.

"Multicast" will execute only from the server, then send it to the clients so that it runs on their machines.

So, when the server presses Right Mouse, "Cli_Dash" runs. "Cli_Dash" is a multicast, but won't execute code on the clients because the "Switch has Authority" node will only let that code run on the server. There's no point in making it multicast if it can't run on clients as well. The server will set the replicated Dash boolean to on, then after a delay, turn it back off.

When the client presses Right Mouse, "SrvDashCall" runs. The "Switch has Authority" node doesn't do anything here, since we already know this RPC only happens on the server anyway. Then "Cli_Dash" runs and should execute on the server, in spite of the issues outlined in the prior paragraph.

The boolean should be updating correctly. Your state machine may have some kind of conflict going a different way.

Try this. On tick, use a "Switch has Authority" node and on Remote, use a Print String node set to last 0.5 seconds. Get the Dash boolean variable and plug it into the text node, which should automatically convert it to "true" or false". When you test the game, it'll spam in the corner but when you press the button, the client should read "true" and you can figure out if the problem is in the networking or not.

[Net Update Frequency] From the other post. "Min Net Update Frequency" determines how often your character updates. "Min Net Update Frequency" is how infrequent the character will update if the character has been idle. I'd recommend making sure that "Min Net Update Frequency" is set to the same as the normal "Net Update Frequency", which is set to 100.

more ▼

answered Mar 26 '19 at 03:55 AM

avatar image

Ray_Unreal
23 1 5

avatar image Glepnizaster Mar 26 '19 at 07:25 PM

@Ray_Unreal I am sorry for the late reply i checked and edited my blueprints. i brought up the "Min Net Update Frequency" to 100 and made the multicast event fire from the anim blueprint. The animation is seen on the server's screen when executed from the client but not seen on the client's screen when executed on the server. ScreenShot-11 shows the Main Character blueprint ScreenShot-10 shows the Event graph in the anim blueprint.

screenshot-11.png (494.8 kB)
screenshot-10.png (745.1 kB)
avatar image Ray_Unreal Mar 26 '19 at 08:56 PM

Dude. Why did you up and change everything? Why did you move the code to the animation blueprint? That wasn't even a problem.

Print String is the best problem solving tool you have. I asked you to setup code to see if the bool was changing on the client or not, then you can figure out if there is a logic problem in your animator or if the variable isn't replicating correctly. I've spent enough time as it is trying to help and typing up a giant thing to just have you ignore what I said.

avatar image Jollhohh Mar 28 '19 at 01:20 PM

@Ray_Unreal i am sincerly sorry, i must've understood ure original reply wrong(the part about the state machine i misunderstood that) also i forgot to mention i did do the event tick print string thing, the boolean changed to true but it alternated as in it printed:( client 1:true, client1: false, client1:true, client1: false) repeatedly until 1.1 seconds finshed(i did do this before changing to the anim blueprint i just assumed that result was fine but if it wasnt i am sorry i did not get back to u about that sooner). I moved the event to the anim graph out of curiosty to see what happened and it ended up working in a way that the the server could see all changes in the boolean(as in it could see the client's animation as well as it's own) but the client could not as if the replication half worked. I also did take out the uneeded switch on authorities that u mentioned and brought the "min net frequency update" up to 100

avatar image Glepnizaster Mar 27 '19 at 02:22 PM

@Ray_Unreal i am sorry i ended up misunderstanding the part about the replication and state machines i also forgot to mention i did do the tick printstring method and got the boolean setting to true and alternating between true and false for 1.1 secs (the delay for which it is true) ure previous replay was extremly useful for me understanding replication so thankyou for your help

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question