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"

[4.6.1] Set Is Replicated causing StaticMeshComponent duplication

Hi,

I will describe the steps I did which led me to this issue (using blueprints):

1) Set the actor blueprint property Replicates to true.

2) Set the value of Should replicate in SetIsReplicated node to true on Event Begin Play for the first StaticMeshComponent (the actor has a StaticMeshComponent by default in its blueprint).

3) Dynamically add the second StaticMeshComponent during runtime to an actor.

4) Set the value of Should replicate in SetIsReplicated node to true for the added StaticMeshComponent.

5) There are now three Static Meshes rendered in the actor.

Does anybody know if this is an issue with a solution or is this simply an engine bug?

Product Version: Not Selected
Tags:
more ▼

asked Feb 04 '15 at 05:49 PM in Bug Reports

avatar image

DarkLiquidus
51 16 21 25

avatar image Ben Halliday STAFF Feb 04 '15 at 11:42 PM

Hi DarkLiquidus,

Please attach a screenshot of your BP setup so we can attempt to reproduce this here. Thanks!

avatar image DarkLiquidus Feb 05 '15 at 12:52 PM

As my blueprint is somehow big (about 500 nodes) here are the screenshots of the crucial pieces of it: alt text

Before this set of nodes there is a Switch Has Authority node and the execution pin comes out from the Authority: alt text

Array Initiation: alt text

Set Transform of Static Meshes: alt text

StaticMesh1 is the starting StaticMeshComponent. DeltaRELCombine is the calculated relative vector determining where the new StaticMeshComponent should be added. StaticMeshComps is an array of references to the StaticMeshComponents in the actor. Other variables are not important for this issue.

avatar image Ben Halliday STAFF Feb 05 '15 at 10:26 PM

I'm not able to reproduce any extraneous meshes. Where is the third mesh component being rendered, and what are you doing to detect it? When I set up something similar to this and use GetAllActorsOfClass to get all the static mesh components, I only get two.

Are you able to reproduce this in a new project, or only your current project? If you can reproduce in a new project, please upload it somewhere like Dropbox and send me a link so I can look into it further.

Also, out of curiosity, why are you trying to replicate a Component of an already replicated Actor?

Thanks!

avatar image DarkLiquidus Feb 05 '15 at 11:05 PM

I think there is actually no third StaticMeshComponent, but because of some issues with dynamic material instances it is rendered.

On the server the meshes become colored in green and red in some places when they enter a certain volume. This effect is not replicated on the client and is actually a desired outcome, but I don't know why the client does not see the change in dynamic material paramaters as the script is launched both on the server and the client. After the addition of a new StaticMesh the client suddenly starts to render a colored StaticMesh placed in the same location which the original StaticMesh component was located, however, simultaneously it renders the real server result in an uncolored version. Here are some screenshots depicting the issue:

-Server (Player 1)-

Before entering the volume

In the volume before addition

In the volume after addition

-Client (Player 2)-

Before entering the volume

In the volume before addition

In the volume after addition

Also, out of curiosity, why are you trying to replicate a Component of an already replicated Actor?

This is because when I set the Replicates property to true and do not set Should Replicate to true on every StaticMesh added, I cannot see any new static meshes on the client at all - nothing happens.

avatar image DarkLiquidus Feb 06 '15 at 03:28 PM

I created another project to check some situtations similar to this one and stumbled upon a slightly unexpected effect. I made an event launching every 2 seconds, which adds a new StaticMeshComponent at a random location. I enabled Replicates property, but did not do anything with Should Replicate property of the StaticMeshes this time. The thing is, when I connect the nodes in the event to Authority in Switch Has Authority node, the added Static Meshes are only visible on the server. However, if I delete the Switch Has Authority node, so that the script runs both on the server and client, the are two StaticMeshes added every 2 seconds. The second situation is explicable as the script runs twice - first on the server and the on the client what gets replicated to each other. I do not understand the first situation. If the actor is set to replicate and the script runs on the server, why the client is not able to see the outcome?

avatar image Ben Halliday STAFF Feb 06 '15 at 05:31 PM

Okay, I think I need to look at the project, as there's a lot going on here and a lot to check. If you can set up a test project that displays this behavior, that would be very helpful. I think it may be a bug that a newly added component does not maintain the Replicates property of the Actor, though I'll need to check into that to be sure it isn't expected behavior. I asked about why you were trying to replicate the mesh on an already replicated actor because it seems like it's the first thing you're doing in your initial description, before you add any new meshes, and that seems redundant to me.

avatar image DarkLiquidus Feb 06 '15 at 06:24 PM

Download TestProject Here is a tiny project depicting the issue. The Authority check is necessary in both this project and the original one as the nodes must be strictly executed on the server and then replicated to clients.

testproject.zip (2.4 MB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

I managed to resolve the issue by getting rid of the Set Is Replicated nodes and making the variable of DeltaRELCombine (the one which is set after calculations and determines where the new StaticMesh should be placed) RepNotify. In the On Rep function I implemented the StaticMeshComponent addition so that it executes both on the client and the server in the same way. I also had to play with the dynamic material instances a bit as they where replicated only upon some significant events.

Thank you very much for your support :)

more ▼

answered Feb 07 '15 at 01:07 PM

avatar image

DarkLiquidus
51 16 21 25

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

So in this test project, the initial cube is replicated as expected, because the Actor is set to Replicate in its defaults. The Switch Has Authority node is making it so only the instance of this BP on the Server is adding StaticMeshComponents, so those won't show up on the Client. If you then SetIsReplicated to true for the components, those components will also be replicated. This works as I would expect it to.

If you delete the SwitchHasAuthority node while Replicates is set to true, the instance on the Server is replicating the code on the Client, so the Client will see both its own added static mesh and another added from the Server (though it won't be at the same location, it'll be at its own random location). This is probably what you were seeing initially.

The best way to get this working the way you'd like, where the Blueprint exists in the level at start, and spawns a new static mesh component on the server and replicates that to the client, is to have Replicates set to True, Switch Has Authority for the random generation, and then SetIsReplicated to True for the added meshes.

more ▼

answered Feb 06 '15 at 09:15 PM

avatar image DarkLiquidus Feb 06 '15 at 09:37 PM

Thanks for the insight, however, the solution you provided is exactly what I have done in the beginning (see the first post) and the result is depicted with the screenshots I uploaded in one of the comments: -Server (Player 1)-

Before entering the volume

In the volume before addition

In the volume after addition

-Client (Player 2)-

Before entering the volume

In the volume before addition

In the volume after addition

avatar image Ben Halliday STAFF Feb 06 '15 at 10:18 PM

I'm not seeing anything like that. Can you update the test project so it reproduces this behavior?

avatar image DarkLiquidus Feb 06 '15 at 11:04 PM

The test project does not contain the actual algorithm I use in my original one, it presents only the concept. As I said the original one is slightly complex and it would most probably take me days to strip it down. There are some graph algorithms, adjecency matrices of Static Meshes implemented whilst the event graph is currently very poorly commented. I tried a slightly different approach and the outcome puzzled me even more. I deleted the Set Is Replicated nodes and here are the steps in blueprint: 1) The addition event launches on the server 2) The crucial values for addition are calculated on the server. 3) After the calculations, another event set to Multicast is called and executes both on the client and the server - it adds the StaticMeshComponent using the replicated values calculated on the server. It seemed like a good idea, but here is the result:

Server:

Server

Client

Client The weirdest thing is that when I actually debug the location values for StaticMesh Components on the client (which are not replicated in this method), it outputs proper values being the same as those on the server. As you can see, in the visual manner the StaticMeshes on the client are completely incoherent.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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