How can I replicate Pawns between a server and multiple clients?
Alright, I've spent the night trying to figure this one out and I just can't.
I've got a pawn, it's controlled by the default player controller. When it's either a single player, or a listen + 1 client the listen/single player moves around fine. The second client doesn't. In the case of a dedicated server neither replicate to one another.
I've also tried making my pawn inherit from DefaultPawn so that it has a movement component however using AddMovementInput ended up with the same results as using SetActorLocation or SetActorRelativeLocation.
What am I missing? Is it as simple as telling the the server the client pawn is attempting to move and to move the pawn on the server?
I built a test project this morning and got it working. I doubt this is exactly what you need but it does what you want. It replicates the movement of the object to all clients using the APawn class only. I have no doubt in my mind that there are better ways because this is sending a lot of data to handle movement... without a full understanding of how the engine does it with the movement components I can't say whether or not the performance with this implementation is comparable.
I tested this using multiple clients on a dedicated server.
NOTE: This does not replicate the rotation unless you are moving forward or backward.. I'll leave that to you ;)
Commence code dump...
Also note that I do nothing on the client side. This is an implementation choice that I made to simply show the replication moving the clients, including the one you are currently controlling.
Hopefully this is enough to get you going!
I responded to another thread about this yesterday - it seems like a gap that should be filled by the team - unless that was never the intention of the Pawn? I'm in the same boat FYI. For now I've just put it on the back burner and moved on.
Here is a way to get it working through Blueprints, though I don't think it is something you would want to do in production code?
There was also mention by JamesG on the forums that they would be releasing some networking pieces around the vehicle stuff in 4.2, that might help us out.
Follow this question
Once you sign in you will be able to subscribe for any updates here