Component Replication with Simulated Physics [bug]

Component replication bug after Set Simulated Physics to true.
Steps to reproduce:

  1. Create new blueprint actor (1st image), set Replicates true. Add one scene component (I’ve tryed few other types, same result) as root component, add and attach 1 Static Mesh Component, choose mesh in the property (use settings - e.g. Simulate Physics false, Auto Weld false but any combination gives the same result.
  2. Add blueprint nodes (1st image). Turn on Physics and Component replication.
  3. Place blueprint on the level (2nd image). Look on coordinates.
  4. Run the game for 2 players and see location of the static mesh component on the server and the client (3rd image). On the client side the root component will be in the right location but any of the attached components will be on the wrong position which is the world coordinate applyed as the relative coordinate.

So the world coordinate offset will be added twice to the component location: first time to position it according to the actor location and then adding the world coordinates instead relative. It looks like a simple math mistake but realy makes unable to use Component replication with Physics simulation. Hope it can be fixed in 4.8 or kind of 4.8.1.

Below there are 3 steps(pictures) that can be easily reproduced.

Hi Trachinusdragon,

I tried reproducing this in 4.7.6 but the actor location remained the same for both server and client. Are you able to reproduce this in a new project, or only your current project? If you see the same thing in a new project, could you upload it somewhere like Dropbox or Google Drive and give me a link so I can take a look? Thanks!

Hello, Ben.
Actor location and the root component location is the same on both - client and server(so actor replication works fine) but not the any of other components. I found this in my big project and then made new clean project and did screenshots you see above. Full project available [here][1] or the only [blueprint][2] you need to copy to clean first person shooter Blueprint’/Game/FirstPersonBP/Blueprints/BP_test.BP_Test’.

Picture - how this project looks on my side

Hi Trachinusdragon,

Thanks for the project! I spoke with the developers about this and learned that only the root component’s physics state is replicated. As such, the physics results are not being replicated properly because your root is not simulating physics. To make this work in your test project, I bypassed the Set Is Replicated for the static mesh components and just used Set Simulate Physics for them on Begin Play. Then I took the root mesh component and enabled Simulate Physics.

Now I’m not sure what you’re attempting to create here, but it seems like you want the root static mesh to remain in place with no physics simulation, and the components to react to physics. In that situation, it would be better to use two different Actor Blueprints, one for the base that doesn’t react to physics, and the other that does. You can then attach the other to the non-physics Actor, and they’ll each respond to physics as you expect.

To properly replicate the change in position as a result of physics on both the Server and Client, you’ll also need to make sure you’re doing all the physics movement on the Server. If the Client is the one changing the behavior, you’ll need to use an RPC call to the Server to have the Server do it instead, because replication in UE4 runs from Server to Client, and not in reverse.

Hope that helps! Let me know if any of that wasn’t clear or you need any further assistance.

Hi Ben, thank you for your answer.

What I’m trying to do is to create a tree constructed from static meshes which are branches, trunk and other tree parts. So I would like to get my static mesh components replicate physics separetely when I turn it on. If you have succeded with the replication of physics in the test project, could you please post it somewhere like Dropbox or Google Drive, because I could not make it work.

The child components movement replication seems to be working properly except the world location coordinates. All of them are moving the same way on the server and clients, but the coordinates of child components are doubled. Pls look on the last picture I’ve posted.

From my point there is bug with replication: right after you turn on “set is replicated” on child componets desregarding set simulate physic is turn off or on root component - child component is shifted on + world coordinate from root component. The only problem I have.

Please open attached project and run for 2 players, then shoot on the server to both BP actors and see the shift in coordinates I’m talking about. The only problem this coordinate shift, everything else works fine!

link

Thanks for the more detailed test project! With it I was able to confirm the problem: at the moment, replicating multiple physics bodies/components within one actor is not supported. The developers have talked it over and will try to move the bReplicateMovement flag onto component rather than actor, which would make your setup work correctly. For tracking, we’ve entered this task as UE-15343, and it sounds like we have someone ready to check something in soon.

I wouldn’t expect this to be fixed in time for 4.8, but I will see if it’s possible. In the meantime, you’d have a better shot attaching actors to actors, rather than using components inside a single BP. Thanks for your report!

Ben, thank you for your reply and task creation, this is what I need. I’m ready to do extensive testing when I have a chance to do it.

The idea why I draw your attention to it - because multiple physics bodies/components within one actor almost working already and I hope UE team need not much efforts to make it 100% working. It is very cool and obvious to have feature of the engine for open world and multiplayer games (lot of different objects and different behavior, but it does not mean lot of them replicate same time - so engine supported component physics replication make life much easier). I guess you can easily imagine hundreds of examples how game developers can use it.

I’m looking forward to test whenever I have chance.

I agree, and it sounds like the developers want to make this work as well. I’ll let you know as soon as I have any information on the update. Thanks for sticking with it!

Hello Ben, just a kind question if this task(UE-15343) has a chance to be implemented in 4.9?

There’s a chance, but I haven’t seen any update on the feature request yet. I’ve emailed the developer who entered the report for an update, and I’ll let you know what I find out.

Sorry for disturbing, have you received any feedback from the developer yet?

Yes: it looks like this has been fixed, and the fix should be in 4.8.1. I’m still testing, but it appears this is correct.

Still not working for me in UE 4.8.1. :frowning:
I used the same test project I attached above.

I apologize, I was mistaken, looks like this is a 4.9 fix at earliest. I’m still confirming, but it looks like it won’t be in any 4.8 hotfixes.

Ben, thank you for update. Hope it will be done in 4.9.

Thank you!!!

Okay, spoke with the developers and it sounds like only the first part of the situation (PreReplication) was fixed, but Replicate Movement is still not implemented. I’ve reopened the task and I will follow up when I have more information. Thanks for the update!

Still not loosing hope to get this feature in 4.9 Preview 4-5. In Preview 3 I see only 2 issues was fixed that before this one - UE-15343 in number. Maybe it is good time to look on it. :slight_smile:

It looks like it’s been pushed to 4.10, as the fix requires a number of risky changes, and they missed the window for 4.9. I’ll let you know if I see any change.

Thank you!