Physics Control Component and Async Physics Thread

Hello everyone! I have a question regarding physics control component, or maybe if there is a viable alternative. Currently using UE 5.7.

In C++, using a regular pawn, I have a joint created with Physics Control Component (PCC) Create Control, think of it as an “elbow joint”. And I really need it to be correctly synced in multiplayer. So next I’m trying to use PCC in conjunction with Network Physics Component, which requires the use of the async physics thread.

But from what I understand and researched, PCC seems to be used purely in game thread, not in async physics thread. And I am really struggling to find the created constraint in Chaos to give it new target orientations, and enable me to use resimulation with the input.

What am I missing? How can I use PCC with resimulation?

To reply myself after struggling the last few days, I managed to get and edit the constraint created with PCC.

After creating control using CreateNamedControl, I added a custom function inside UPhysicsControlComponent to dig the internal FPhysicsControlRecord and return the FPhysicsConstraintHandle given the control name.

With this FPhysicsConstraintHandle, here being the variable ConstraintHandle, we get the Chaos::FConstraintBase*, followed by the IPhysicsProxyBase*. Then we cast it to Chaos::FJointConstraintPhysicsProxy* and store it. We cannot immediately use it because the underlying Joint Constraint takes a while to be created after the initial control creation:

// On control creation, we can (mostly?) safely get the proxy handle to Chaos joint constraint proxy

Chaos::FConstraintBase* BaseConstraintHandle = ConstraintHandle.Constraint;
IPhysicsProxyBase* ProxyBase = BaseConstraintHandle->GetProxy();
Chaos::FJointConstraintPhysicsProxy* JointConstraintProxy = static_cast<Chaos::FJointConstraintPhysicsProxy*>(ProxyBase);

// After component has spawned or some time has passed, we get the final handle

Chaos::FPBDJointConstraintHandle* JointConstraintHandle = JointConstraintProxy->GetHandle();

// With this final handle we can edit the joint data, enable it, etc, directly on async physics thread

JointConstraintHandle->SetEnabled(true);

I’m not in any way sure this is the best way to go about this, but it is working at the moment. Still not sure if it is 100% working with resimulation, but current multiplayer tests with a friend are promising.