x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: Not Selected
Tags:
more ▼

asked Mar 29 '14 at 01:46 AM in C++ Programming

avatar image

Sam_Hi
13 3 4 6

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Mar 29 '14 at 02:09 AM

avatar image

Rama
10.5k 443 341 1078

avatar image Sam_Hi Mar 29 '14 at 08:29 AM

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

avatar image Rama Mar 29 '14 at 05:03 PM

//constructor

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


Enjoy!

Rama

avatar image DarthB May 01 '14 at 06:41 PM

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.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question