How can I get a StaticMesh to sync its location to clients?

I am trying to implement multiplayer from a Basic Code template, but I came across a few problems.
I have already successfully made multiple spawns with C++ code and player locations are already in-sync.
However, the EditorCubes that come default in the First Person Template are not syncing locations to the clients.
Here’s what happens:

When the host client (hosting the listening server) moves a cube, it doesn’t update the position of the cube to the other connected clients. Although the newly moved cube hasn’t updated location to the connected clients, they can still collide with the cube and move it (as shown on the host client’s screen), but it just looks like they’re colliding with nothing.

There is yet no official documentation of how networking works in UE4, so I’ve been taking random guesses to try to get it to work. Unfortunately, nothing seems to work. Any help would be greatly appreciated.

#Solution

Make a BP of Static Mesh Actor Class

open the defaults

do a filter for “rep”

check all the replication options so they become active

use only this custom Replicating Static Mesh, for any SMA that should replicate

and you will be good to go

Rama

Thanks, that worked perfectly!
Is there any way to do this via C++?

//constructor

//Replication
	SetRemoteRoleForBackwardsCompat(ROLE_SimulatedProxy);
	bReplicates = true;
	bReplicateInstigator = true;			//for projectiles, see actor description
	bReplicateMovement = true;
	bStaticMeshReplicateMovement = true;

#Enjoy!

Rama

Hi,

I was wondering if it is possible to change the replicate flags somewhere outside the constructor. (Like in the ConstructionScript)

Use-Case:

I have an Actor that has a flag: bIsPreview and I want to use this flag to change the replication flags. I know this parameter bIsPreview before construction so I hope I just have to find the correct hook. OnConstruction() does not seem to work here.

Edit:
Stupid me saw the SetReplicates method today and if I’m using the method to turn on replication in OnConstruction() then everything works.