I have my character’s rotation set in the playercontroller’s tick event (top-down aiming). The client can see the server’s pawn rotating, but the server (and other clients) cannot see the client rotating. How can I fix this? I tried re-wiring the tick event using RPCs but it still doesn’t work.
One client’s playercontroller actor doesn’t exist for others, so they can’t access its rotation.
A way to get around it would be a UPTOPERTY(Server) type RPC, that takes a FRotator or FQuaternion type argument, which then sets the pawn’s rotation to this value. You need to call this function in tick, passing the playercontroller’s rotation.
This will make the client take its rotation, that only it can see, and send it to the server as an argument, which in turn updates the rotation for every client.
I get that a client’s player controller doesn’t exist for others, but shouldn’t the rotation of the pawn changed by the controller be reflected in the server since the pawn itself is replicated, thus the rotation of the pawn is also replicated?
I think that’s pretty much what I did with the RPCs, but I’ll try it again.
Thanks
Fixed it (kind of…) ! Thanks to AdamBors (upvote his answer.)
Had to first execute it as server, and THEN multicast it.
I still feel like there’s gotta be a better way to do this stuff… What about when you have so many variables that everyone needs access too? Will you really have to create that many events?
What if you set the actor’s rotation inside UpdateRotation1? I think that should do it as well.
Also, the characters’ movement component has a bool that makes it automatically rotate in the camera’s direction, not sure what it’s called. Have you tried that?
Nah, it doesn’t work. That way basically inverts the problem, it shows it on the server but not on the client. So I have to multicast it so that everybody can see it too. I still don’t like this solution, though… If the server has an unreliable connection, then the aiming will also be unreliable for the clients… Is there no way to replicate something from a client to the rest? Or is there a way to execute this event locally for the client, but replicate it to the network for everybody else? That way it will be reliable for the client, but not reliable for the other clients/server, because it doesn’t necessarily have to be. Thanks again!
Did you check the settings of the movement component? There should be a checkbox for just this. In code it’s “GetCharacterMovement()->bOrientRotationToMovement = true;”, not sure what it’s called in bp. Invert its value and your character should start following the camera’s rotation automatically.