Replicate Character Rotation between Client and Server

Hey Guys

I’m struggling a bit with getting the replication to function correctly between my client and server. At first I used the “Pawn” class for my custom class but soon found out that the movement doesn’t replicate, so you’ll have to create you own replication code. I got it working but not 100% correctly. I then switched to using a “Character” class as the movement component already had replication and network smoothing build in. The problem I have now is that my movement is replicated correctly over the network but not the rotation. The rotation is correct on the client, but it’s not being replicated onto the server.

Does the “Character” class not replicate rotation ? Can anybody help me in getting the rotation to replicate ? Also. Does the "network proxy ( ie. the clone of your pawn on the server) " of your pawn not have a controller ? I’m very new to all of this so still trying to get my head around it.

Thanks
A

Replication works in opposite way - variables from server replicates on client. For sending data to server you need RPC.

If you’re using simpleMoveToLocation or even moveTo then you right - it doesn’t replicates correctly. If you move/rotate a pawn by yourself, you can hold location/rotation variables, make them replicatable and on the client you’ll have correct values.

But at the moment I’m not calling the MoveForward or MoveRight functions only on the server. I haven’t specified any UPROPERTY() for those. So how do they then replicate but not the rotation ?

I’m using “AddMovementInput” for the forward/right movement and “AddControllerYawInput” and pitchinput for the rotation.

Because Character holds movement component and it’s replicated by default (you can check it in blueprint). It seems that rotation is managed differently or not managed at all. So you need to add add some field, say MyRotation make is replicatable, on user input you say server to change characters rotation and you’ll get correct value on client. All you left to do - update orientation with this value.

Ok thanks, I’ll give that a try when I get home. Maybe one of the Devs can shed some light on why the rotation is also not replicated by default ? Or if we have to do something differently perhaps ?

Hey guys. Ok for some reason it’s working now. I’m updating my pawn’s rotation locally and calls a function on the server that updates it’s rotation. It’s working 100%.

what is the function you are using on the server to update the rotation? because I’m having the same problem.

I just got over this hump myself. In my game the character is controller normally through wasd and rotates towards the mouse like in Alien Swarm. The rotation is calculated every tick and I call an rpc every net update interval to set the rotation target on the server, which is then propagated to the other clients through a replicated variable. The non-controlling clients interp towards the desired rotation every tick. In my version, I had issues with floats getting a little jumbled every now and then which would cause them to twitch a little, but only when standing still, so I added in logic to not update when the rotation hasn’t changed. Not sure this is 100% the best way to do it, but for now it works. If it shows issues in playtests down the road I’ll scheme up something better.

Hello guys. I have a similar problem. I’ve been searching the forums for a solution but it seems that I can’t wrap my head around it. I am new to UE4 (and especially networking), I understand the basic concept of networking on UE4 that the client must always send info to the server and the server will replicate to other clients, but still I can’t figure out what is wrong in my handling.
Here is how I am doing it:

  • On the controller blueprint I am handling the player inputs: Every tick I calculate the rotation where the character should look at (this in handled in the CalculateMouseInputRot macro) and set the ControllerInputRot variable. After that I notify the server about the rotation of the character by calling an event which is located on the character blueprint (the macro NotifyServerAxis is triggering this event)
  • On the character blueprint I am handling the server event and set the calculated rotation into a local replicated variable PlayerRot, set the rotation of the character and trigger another event which will multicast on all clients.
  • On this multicast event I just update the rotation for all clients.

I really can’t figure out what am I doing wrong. Can anybody have a look and maybe give me some hints?
Thank you!

http://i.imgur.com/4Gaheu6.png
http://i.imgur.com/TmAzLMZ.png

Coming across this problem in 2020 and still none of the solutions here are optimal.

RPCs should be for one off events and shouldn’t be used in tick events to update a variable. Variable replication is done only roughly 10x per second so as not to overload the network rather than each tick.

The server should already know about each characters rotation, it just isn’t multicasting it.
The best way I’ve found to do this is create a rotation variable in the character/pawn and set it to replicate. Then in the tick event, update it from the control rotation.
I just needed the pitch because the yaw already replicates fine.

Character Blueprint

Hey m8. coming across the same issue in 2021 and i think your solution could help me out. what are you doing for remote?