Download

Multiplayer coding requirements?

I am trying to create a multiplayer game. I have a player class with both 1st and 3rd person meshes and they show up as intended. When I try to run the game, the two players can see each other move around just fine. But if I start a game using the sample level that has the stacked cubes here and there and I move the cubes around, only the player that’s doing the moving sees the changes. The cubes don’t move for the other player. It seems each player is running his own copy of the server. But how is it that each player can see other and collide with each other?

So my question is what needs to be done to create a networked multiplayer game where there is a server and clients? The old quake games had seperate code for each and clearly defined hooks for receiving events like ‘player join’ and ‘player leave’. The client/server distinction seems pretty murky in UE4. Is there a roadmap somewhere for creating a multiplayer game in UE4?

Hey, I highly recommend the following series of video tutorials on the subject: https://forums.unrealengine.com/showthread.php?2956-New-Blueprint-Networking-Tutorial-Videos-Posted&p=20354&viewfull=1

Basically actors can be individually flagged for replication. In the example, the boxes are not flagged for replication while player pawns are by default.

Hmmm, the boxes are marked for replication (I think I checked the correct box).

I have watched the video series a couple of times. But the info provided is pretty thin.

Whammy,

I’m not sure but doesn’t the cube you are moving is managed by physics? If so, it’s not networked (as far I know).

thanks,

Whammy, besides checking ‘Replicates’ did you also check ‘Replicate movement’?

I got some simple physics replication working in the First person template by creating a blueprint, checking ‘Replicates’ and ‘Replicate movement’ in the blueprint’s defaults and adding a Box component with ‘Simulate physics’ checked. When pushing the box around, the box will stay synchronized on multiple clients. However, when shooting the box from a client that is not the host, the client will desync. I think this is because projectiles are only spawned and physics simulated client-side.

Hey i had this same issue working on some physic dependent actors.
Two things first for a multiplayer game always spawn a item server sidee, and have it replicate to all clients.

For the physics that is out of sync located in the USceneComponent:: are.


SomeCompoent->SetMobility(EComponentMobility::Movable); // Makes physics in sync for all client(s) and/ or Server

Its worth to note that when running PiE it tends to be somewhat out of sync event then.

For more info see the AnswerHub post i found this solution.
Actor Movement ‘Physics’ Replication

Hope it helps.
WCode

I think the problem is that the cubes in the example map are just plain old static meshes. I suppose that if I blueprinted them, it would allow more options.

I think you’re right on that. The answer in WCode’s link also does the same things as I did, but in C++.