Ragdoll physics replication - Sync

Hello!

I’m currently testing out a few ideas. And one of them involves ragdolls, which actually affect gameplay, as physical objects, for example as obstacles, or objects players are expected to further interact with. So it is crucial to keep ragdoll positions and their poses in sync.

So, is there any way to replicate ragdoll physics from server to clients in UE4? If not, is it worth to try and find a blueprint-based workaournd for that? Say, each tick grabbing position of each ragdoll’s component, and forcing clients to transform it the same way?

Blueprint solutions preferred, however if it can only be done through C++ - I could consider those options as well.

Thanks!

i think physics is not replicated because of heavy calculations… im not sure if this is possible in BPs…
I really dont know what you want to do, but imo one option is to replicate actor position with “ragdoll” attached and do client-based physics body simulation… for example if you throw “player’s body” 100m away, everyone will see where body is but it will be unfolded on every player PC differently

Well, I don’t think that “calculations” are the reason for not replicating something. It will just put more stress on the server PC, and network bandwidth, while clients with just have to position objects at give coordinates.

The way I see it, is that ragdolls could be replicated the same way as any other physics enabled object is, in unreal. Basically, server simulates the motion, and just sends coordinates of each joint\object to the clients. It’s just about how many objects there are. So I’m looking for any built in functionality for that.

replicating only one object is an option, of course.

What I’m trying to do is ragdolls damaging other characters. Imagine a grenade going off near a few characters. It kills them, and launches their ragdolls into the crowd of other characters behind them, and they have to kill or damage those other chars on impact.

It works perfectly fine in singleplayer, with true collision detection and impact force calculations. Now i ‘just’ need to replicate it :smiley:

I would only calculate the physics server-side and then sync the results with a replicated transform and perhaps a lerp on the clients to smooth it out.

Problem with this approach is that client’s physics interactions will be based on their server version which might be inaccurate and delayed. No clue how to do it any way else.

Question is - how do I do this? What is the correct way to do this? I did not find a way to set bone rotations on animated skeletal mesh through blueprints. Posable mesh seems like it does not have an animation blueprint. And I also do need a ragdoll simulation capable of shooting out Hit events.
I’m missing something, I think.

I don’t think that clients really need to simulate anything gameplay-specific in my case. All gameplay-influencing physics calculations could be handled by the server.

Oh, excuse me, I didn’t read you were trying to simulate bone physics. I merely thought you wanted to sync regular physic objects. I can’t really help with skeleton physics, I’m still very new at that myself.

Do a search for networked physics and @TheJamsh on this forum.
You should come across a thread talking about networked physics that also links to this:
https://github.com/TheJamsh/NetworkedPhysics-OLD

With any luck, that will help you get started.

There’s a newer version of that now here: https://github.com/TheJamsh/UE4-Networked-PhysX-Component

However, it’s for predicting movement for Pawns that use PhysX and not much else. PhysX replication is hard and expensive, and tbh you’re better off changing the game mechanic to avoid replicating bone transforms.

Ragdolls should be made to not affect gameplay. Gears of War 2 actually had some fairly critical online problems because of this.

Personally I’d just replicate the position of the root bone and then let clients handle everything else. That would probably be good enough for most games.

Not if you want to actually make it possible to kill someone from collision with a ragdoll. And my ragdolls don’t even have a lot of jonts to simulate. Each one has about 4-6 simulated objects, but it’s just much more convenient to use ragdoll, rather than building it out of multiple objects manually. I don’t see a lot of difference between replicating 8 separate objects, or a ragdoll with 8 objects, in terms of bandwidth and calculations. Is there?

Other than that, yeah, probably will have to find a workaround, or limit it to singleplayer for now.

Is this a thing yet? I’ve tried everything to get that good Gang Beasts skinned mesh ragdoll replication and it just never works.

Is there a way to take each bone and manually make them relocate? Like set each bone location?

I know it’s been 5 years but to anyone reading this I think you could use snapshot poses that send from the server to clients every tick and lerp between them somehow, I’m trying to do something like that in my own project.

1 Like

Hi, did you managed to find a solution for this issue ?

To achieve my specific goals, I’ve focused on accurately replicating the hip transform. Within the player Blueprint, I’ve created a physics constraint that constrains the hips to the world using both linear and angular motors, which are initially deactivated. It’s important to note that physics constraints are relative to their initial positions at the beginning of the game.

Upon Event BeginPlay, I record the starting transform and employ a boolean check to determine whether the player is locally controlled. If “is locally controlled” equals false, it means that the player Blueprint is executing on a remote machine. In this case, I activate the linear and angular motors.

During each in-game tick, the client’s transform relative to its initial position is recorded and then synchronized with all other clients via a server event followed by a multicast event. This synchronized transform serves as the new linear and angular targets for the motors of other players.

In summary, this setup involves a linear and angular physics constraint motor that operates exclusively on players other than the client. It constantly updates the hip transform for all clients, ensuring that the motor’s targets remain current.

However, it’s worth noting that this approach has some drawbacks, including client-authoritative movement (which can be exploited by hackers) and a delay when one ragdoll player attempts to push another ragdoll player.

1 Like