Hey guys, I am trying to set a variable (the characters speed) on all players, so the animations play correctly for them. On the server, the variable has the correct value for all players, but the clients dont even get their own variable right, even though the variable is set to be replicated and therefore should be set to the servers value on all clients, right?
Should cover all your Networking Questions (guess thats better than giving a straight Solution). You could also Download the Content Examples Project from the Learn Tab it has a whole section dedicated to Newtworking if you need something to look at.
Good Luck mate =)
I will give u the answer but you also need to listen to Nachtmahr, because I think you are missing a bit of knowledge about networking.
So what you are doing right now is you are getting the velocity from the client side and the sent it so the server so u are getting a value that is not correct(because as you said it yourself: the clients don’t get theyre own variable right).
So what u need to do is you need to do is connect the vectorlength straight to the variable of the server(so plug it in after the event “setspeedonsv”) and remove the parameter on the event because you don’t need that one. You can also remove the “setspeedoncls” event because the variable is replicated and it comes from the server the variable gets automatically set on everyone.
Regards.
Thanks a lot, I am pretty unexperienced in UE4 and only started learning about networking recently, so your help is really appreciated. But my problem is that if I execute the “velocity → vectorlength” on the server for a client, it shows 0 because I dont have character movement set to be replicated (since it causes stuttering for the client) and I update the characters location/rotation every tick (thats how multiple tutorials told me to handle it).
So for the server, the players dont have a velocity, they are just getting teleported around, thats why I need to get the velocity from the client, and somehow send it to the server and get it replicated for all clients.
Am I completely misunderstanding how to approach replicated movement or is there any way to get a variable from the client to everyone else? Thanks in advance
Well, if u want to do it that way(Without replicating movement) then you need the input in the setspeedonsv event. but not the setspeedoncls because like I said the variable is replicated.
But I will give u a tip: 1. Please avoid replications on tick(What u are doing now) Because you are replicating multiple variables per tick, this can cause the client to diconnect and can cause lag. So I advice u to just use the movement replication and u can always smooth it out(Just search for some tuturials) Ofcourse replicating movement also causes multiple variables to replicate on tick but that happens in an efficient way.
Regards.
Here is a screenshot of the networksmoothing(In the movement component)