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.
If single player, works
If Listen and 1 client, Server works
If dedicated server, none of the clients replicate
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?
Look at the pawn class (and other classes) of the ShooterGame example. It is a fully functional multiplayer shooter game. Compare the classes [mostly the values set in the constructor] and see what you are doing different.
It’s really difficult for someone to answer a question like this without the full details of your entire setup. It could be 1 or more of many things but I would start with the ShooterGame example project.
Unfortunately the problem comparing the two is all moving/replicated Actors in that example are inheriting ACharacter. My current game is inheriting from APawn or ADefaultPawn because the Mesh doesn’t have a skeleton. The problem I’m describing above even happens with the flying template if you attempt to play it multiplayer. The second ship doesn’t appear to be replicated on a listen/client setup, and neither appear to be replicated on a dedicated server setup. This is all with Replicate and Replicate Movement turned on.
Well then, my guess would be that since you don’t have the UCharacterMoveComponent that comes with the ACharacter class, none of your movements are being replicated. Look at the UCharacterMovementComponent and you can see it uses the interface INetworkPredictionInterface.
This is the only major difference I can see between APawn and ACharacter that relates to movement.
The UMovementComponent doesn’t utilize this interface and maybe that’s why it’s not replicating. Can you try to stick a UCharacterMovementComponent on your object and move it that way? Maybe it will replicate the movement then.
I’m simply trying to work through the possibilities with you, I’m no UE4 guru =)
When you are a Listen Server, you act as the server and a client… nothing is being replicated anywhere… technically. You are playing as the client, but the other clients talk to you rather than a dedicated server. So you are seeing your own movement locally as if you were just a normal client. When you spawn in another client that connects to the game the Listen Server is hosting that is the true replication there… the Listen Server is not replicating any movement so you don’t see each other move.
Oh my… I completely missed that. I misunderstood your first post, I’m sorry.
So… you have a Listen Server with another Client connected to it. From the connected Client you can see the Listen Server Pawn moving around, but the Lister Server can’t see the Client pawn move. This is odd indeed.
You know what… it might be that the second client isn’t sending any of it’s movements to the server, kind of like sixb0nes was saying. Look at my first comment on sixb0nes’ post there and that is what you need to implement. The Listen Server moves fine and replicated because it is the server… you are telling the server directly to move so the other connected Client sees the movement.
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.
Right, but there are tick boxes to “replicate movement” when blueprinting, etc. and they seemingly have no effect? Again, maybe using the Pawn for a purpose (character) that it wasn’t designed for and the assumption is that you will be handling it on your own. Seems odd.
I’m pretty green too, so I may be completely out to lunch as well
What I don’t understand is why does the movement replication work on a pawn when one player is also acting as the server? The server/client machine has it’s movement replicated onto the connected client machine no problem while the connected client machine doesn’t.
I do agree that this seems like something that should be filled in by the engine.
Giving it a go though I do notice it requires a reference to a character. I may take a look at all the network prediction related code in UCharacterMovement and see if I can’t make it work in a custom movement class that doesn’t depend on the character.
I may have not been clear, or perhaps I’m not understanding what you’re saying. When I setup a listen server and a second client the listen server/client movement is replicated to the second client. That’s where my confusion lies. So there’s clearly something going from the listen server to the second client letting it know that a pawn has moved.