Networked Physics with PhysX

After some tests I noticed that I get this error only when in the scene there is a vehicle… So there is something wrong when I pass the vehicle to the secondary scene.
My speculation is that since the vehicle has attached the 4 wheels I have to pass to the new created scene both vehicle body and attached wheels that probably are not dynamic actors.

I’ve found another way of rewind / replay all moves.
Instead of create another Scene I will use the main scene.
Before Reply back all moves I will remove all dynamic actors from the main scene exept “My pawn” then I call these functions simulate and fetch result all times I need that then I reinsert into the main scene all removed actors.
For now this solution seems good but I will let you know if it works as I’m expecting.

@B1TZ3R0 Hmm, my vehicle also has attached wheels but I get the PxActor manually from FBodyInstance and transfer it that way.

Do you take it in this way?


PxActor* PActor = GetMesh()->GetBodyInstance()->RigidActorSync;

Yes, there are also other ways but this works just fine.

Due to some problems that I having with this code, It’s a problem if you show me exactly how you take this actor?

Reinserting actors into the scene isn’t cheap, so this will only really be fine for a small-scale solution.

I’ve found another better solution, that not Imply inserting or removing actors, But First I want finish the job!

Sorry for not responding earlier :stuck_out_tongue:


PxActor* ActorToAdd = BPMesh->GetBodyInstance()->RigidActorSync;
	GetWorld()->GetPhysicsScene()->GetPhysXScene(EPhysicsSceneType::PST_Sync)->removeActor(*ActorToAdd);
	PScene->addActor(*ActorToAdd);

Sorry if this question comes up a lot, but I really don’t have time to read through multiple threads of discussions. I read the four pages here and couldn’t find a satisfying answer.

What are currently the best solutions to replicate ragdolls? I am not talking about 100% replicating all movement, I would be fine with just having the pelvis in the right location and orientation on all clients and the limbs client-side.

I basically need to have players being able to hit other players unconscious with them falling down in ragdoll mode and later getting up again at the same position on server and all clients without desyncs. I don’t care if the arms are in different locations etc, I just care about the general position of the body.

Are there good solutions for this at the moment? Would this networked component help with this or is it only feasable for full rigidbodies like hard objects and vehicles?

Yeah, the system we’re making is for rigid bodies - so it’s not doing bone-level replication and prediction - it’s just the entire object. Individual items like suspension bones etc are still handled client-side.

If you want Ragdoll replication, you can use standard UE4 replicated movement for that. It’s not really feasable to replicate a full set of bone transforms, it’s just way too much data. Typically however, ragdolls aren’t really relevant to gameplay (as in, they have no collision and are visual-only elements). I’m warning in advance - Ragdolls in Gears of War 2 still had collision enabled, and it caused a host of problems for clients. In Gears 3, ragdoll collision with bullets etc was disabled.

But how would I do that? When a ragdoll is simulating, it will eventually move away from it’s root bone. As far as I see the only way would be to replicate at least one of the simulated bones, like the pelvis.

That’s why I only want to replicate one bone if possible. Unfortunately, for us ragdolls are gameplay relevant (and recent UE4 games like Conan Exiles somehow managed to replicate ragdolls as well, so I don’t have the excuse that it “won’t work in the engine”). Like I said: I am not interested in full ragdoll replication for each bone. I just want to make sure that ragdolls, regardless of individual limbs are in more or less the same location, so I don’t get glitches and desyncs when I blend back to animations.

But yeah. I had hoped your networked component would help me in that ‘little’ quest. I guess I have to experiment a bit more. Thanks for the quick answer anyway!

I been having the same problem with my project, but in my case I would need all of the bones synced. I’m just wondering how Source Engine does it so well

Yeah, you’ll have to sync the transform and velocities of the Root Bone and apply them as necessary.

It’s expensive, and it’ll look weird because bones will just keep snapping to different positions as you get updates. Source probably uses a deterministic physics sim… not sure.

Hello, I and an artist are working on a multiplayer game with drones (so, they don’t just hover, they can go up and down) and we use physics for its movement, AddForce and stuff.
I implemented TheJamsh’s project from Github in our game, adapting its PerformMovement function to use our movement code, everything else is the same. Everything works as excepted, move replaying, synchronization of movement, all perfect.
The problem is this:
If I play in-editor with two players, with Use Single Process checked, everything is perfect. However, if I turn off that option, or play it by launching two game instances from the .uproject file, when I enter the game map the server pawn works perfectly, but, if I have focus on the client window, its proxy on the server window starts falling, and if I focus the server window, that same proxy starts going up. As the locally controlled pawn on the client is working well, it should stay “floating” in the air, but as its proxy on the server side is moving, their difference in location becomes very large, and the local one gets its position corrected, making it jump from location to location on the z axis.
So, the correction logic and movement synchronization is working. I just don’t understand why it starts falling out of nowhere or going up like crazy. All of this happens even if I don’t ever touch the controls.
Gravity is always enabled, and physics simulation is also always enabled, and we have a force to counter act the gravity force, so it should just stay there hovering… Because in single player and in multiplayer in-editor with Single Process it works perfectly…

I’ve tried everything, unchecking Allow Tick before Begin Play, Allow Tick Before Owner, and many other things, and nothing worked, almost half a week trying to solve this and nothing, don’t know what else to try.

Does anyone have any idea what it might be?

Thank you.

Probably because Delta Time is huge when you aren’t focused on the window. To be honest it’s hard to say.

None of that code I provided is production ready, in fact there are still some massive flaws in it!

I kinda gave up on rewind/replay, I decided to go full client authoritative movement. I still plan to check on the server for any weird movement that is the result of cheating.
I got rewind/replay working for vehicle but not sure how to handle dynamic collisions.

Thank you for the reply.

I guess that makes sense… But, if I use your precompiled project, by launching two instances of the game, your movement works perfectly… Mine only works if on Single Process…

Since your guess is that Delta Time is huge when the window isn’t focused, do you think it could work if each instance was used in different computers, meaning both windows would be focused all the time?

I know, but still, it is a great help!

If you add lag, you’ll notice it definitely doesn’t move perfectly :wink: That would possible work, but the problem then is you can’t guarantee a user will have focus on the window. I’m not sure how to get around this atm, other than clamp the incoming delta time, but that has issues of it’s own.

If you got that working, would you mind sharing regardless? Some of us might not mind dynamic collisions so much :slight_smile: