How am I able to Replicate movement when using "AddMovement Input", but not AddLocalTransform?
I can clearly see that AddMovement Input is the better way to move a box around, but I'm looking to understand why LocalTransform doesn't replicate.
I'm only moving a box forward and backward in this small example.
Here's each Blueprint script:
Both the client character and server character move just fine when I use the below script:
But in this next script, I can only move the character on the server instance. The client character jitters when I try to move, but the server seems to be keeping it in place and not allowing it to move.
For trivial purposes, how can I have LocalTransform replicate (enable the client to move)?
We automatically handle replication for you from client -> server for movement input. The simulation happens locally on the client and the acceleration/input values are sent to the server for the simulation to occur there as well.
However when you try to simply set the client's location (only on the client), the server doesn't know you tried to do that, and it will think the client is out of sync and send a position correction to the client to fix it up (the jerkiness you saw).
There are a few ways to approach this:
1) If the teleport on the client is caused by player input, move locally and then use an RPC to the server to do the same thing.
2) If the teleport is caused by an interaction w/ the world (a volume for example), you can have the volume trigger only on the server which will then correct the client's position as well. Or you can simulate the change on both client and server, so the client doesn't have to wait for the server's correction (reducing perceived latency).
3) There is a config option for "ClientAuthorativePosition" [sic, I know it's misspelled] on the GameNetworkManager that changes the rules: the server will accept client movement as authoritative and not force a correction if it's within a squared distance (MAXPOSITIONERRORSQUARED) from where the server last saw it. So in this case, the server would warp the character to where the client tried to move, and the client's position is the authority. The server can still replicate movement to the client normally, this just handles rogue client movements.
You set this in your game ini settings:
answered May 05 '14 at 05:45 PM
we cant have our pawn locally controlled if we check the box "movement replication" because the server will correct our client position every time we try to move locally...
but then you said we can make the client authorative on his position, this still work? i cant find any game ini at all
i just found a DefaultGame.ini and i tried to put those line inside it, but this dont work, client isnt authorative, or i did something wrong but cant find what
if someone know how to force client to be authorative, tell me pls :), where to find this game ini settings file?
answered Jan 16 '16 at 12:35 AM
I'm understanding most of this now.
Replicating a blueprint variable only replicates that variable from server to client. You need to define an RPC function that the client calls on the server and pass whatever values that you want replicated from the client to the server. Here is the blueprint logic:
I guess my last question would be:
Replicating an actor does not automatically sync the actor transforms? It seems that "Add Movement Input" is replicating the input and executing the input on the server, where as actor transforms are not automatically replicated when modified. Is this correct?
Follow this question
Once you sign in you will be able to subscribe for any updates here