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.
I am very confused about the purpose of “Switch has Authority”. I have the editor configured to spawn a dedicated server with 2 clients, but each client apparently “Has Authority”. My impression is that only the server would have authority, per the explanation in “A Crash Course in Blueprint Replication - Unreal Engine”.
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:
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?
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?
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:
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.
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).
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.
for my project I need a constantly updated float variable to be replicated to set an aim offset. I have tried countless different ways of setting this up but none work.
the custom event “look” is powered by the main tick and is not replicated.
the variable “camera rot” is set by the tick to the relative rotation of the camera arm.
all variables are set to replicate
the custom event “update look angle” is set to “run on server”
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.
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?