Pawn movement replication

Hello everyone,

Lately I have started to mess around with multiplayer things. I quickly ran into this issue where pawn movement doesn’t seem to be replicated from the clients to the server. The pawns were at one point using physics based movement that wasn’t replicating then I read that physics movement cannot be replicated and changed the movement to the blueprint you see now. The issue is that the movement of the clients isn’t being replicated to the server. Any and all ideas are welcome. Went through quite a few tuts on the subject already, and it seems from the research I have done that this should be working.

Link for full res: http://imgur.com/ovZH55p

If i’m not mistaken, replicated movement needs the standard “CharacterMovementComponent”.

So you need to ALSO call RPCs (RunOnServer) to let the Server move the Client on his side.

Yup what exi said.

When doing multiplayer in unreal you should think about clients as things that have only keyboard, camera and hud. Everything else is done on server almost like you would do singleplayer.
All clients only peek trough monitors to see what server is doing.

For replicating stuff from server to client pawns, great way is RepNotify for variables. You can hide whole logic in those on_RepNotify functions. I did all hit emmiters, laser pointers, all visual stuff that does not change game this way.

Also use game state or game mode as your brain for game on server. I am using game state for gameplay related things and i plan to use game mode for session manager, chat etc later.

Thanks a lot! Switching to a character class and using CharacterMovement works beautifully, I don’t know why that never came up when going through all the resources I did.

Hi Exi, I am trying to do something similar but cannot use the character movement component. Is there a way to override some of the pawn movement functions in bluperints in order to create the movement replication like in the character class? I have been reading through the character.cpp and .h files but am having trouble understanding where and when the movement is replicated in order to recreate this for the pawn.

Thanks very much.

For non character pawns you can learn a lot from this thread.

That is all physics based movement. I got that part done quite quickly.

I’m have trouble with adding movement input to the floating pawn movement component and having it be replicated from the server to the clients. I have tried several different things but none of them work completely or very well. Some don’t work at all and I cannot understand why it would or wouldn’t work.

For example I have an axis input which goes to a custom event that is run on the server, is replicated, and reliable. That event adds movement input. When the client calls the event the server it will execute the event and receive the correct input values but it will not add any movement input or cause the actor to move on the server or the client. Using the same setup if I run a listen server and control an actor from there it will move itself on the server and that movement will be replicated to the clients.

For adding force and setting rotation on the server by calling a server function from the client both force and rotation can be set. If I do the same thing by adding movement input or setting the velocity of the movement component it does not replicate to the clients.

This is because the force and rotation are handled somewhere in the pawn or actor class or something higher up where the movement component does not handle the movement replication. This movement replication is added in in the character movement component. I’m trying to implement that kind of movement replication in the pawn movement component without adding in all the other restrictions and methods that come along with the character movement class.

I’m guessing this will not be possible in blueprints in any acceptable way.

1 Like