Physics Joint Example/Sample

Can anyone provide me an example of how to implement a Physics Joint, specifically a FixedJoint between two entities? I’ve created the physics joint using:

PhysicsJoint.CreateFixed();

But I have no idea what I’m supposed to do with the joint? Where do I apply it? Apologies in advance if this is a really stupid question.

I did look at the RagDoll example but they use a function called CreateJoint() which I can’t seem to find so I don’t know if the function name has changed or I’ve missed something.

This is what i do for a joint between entityA and entityB and works for me. I use a new separate entity to hold the joint because i have multiple joints on the same rigidbodies. If there is only one joint you can place the joint on entityA or entityB

Also you could ask chatGPT for more examples (although it only knows about older versions of ECS)

EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

RigidTransform rigidTransformY = new RigidTransform();
rigidTransformY.pos.z = 20f;

Entity entityJointHoldery = entityManager.CreateEntity();
entityManager.AddSharedComponentManaged(entityJointHoldery, new PhysicsWorldIndex(0));

bodyPair = new PhysicsConstrainedBodyPair(entityA, entityB, false);
entityManager.AddComponentData(entityJointHoldery, bodyPair);

joint = PhysicsJoint.CreateFixed(rigidTransformY, new RigidTransform());

joint.SetImpulseEventThresholdAllConstraints(80f);

entityManager.AddComponentData(entityJointHoldery, joint);