Multiple Physics Handles

Hey all,

I’m trying to grab multiple pieces of a destructible object. I can find all the bone names, locations etc which is fine. The issue is when I try to “grab” these objects.

For instance if I have the following it grabs the right bone and moves around:


PhysicsComponent1->GrabComponent(BoneInfo1) 

On the other hand, the following sets both physics component to have the same bone information:


PhysicsComponent1->GrabComponent(BoneInfo1)
PhysicsComponent1->GrabComponent(BoneInfo2)

Stepping through the code PhysicsComponent1 has the correct bone information until PhysicsComponent2 grabs a bone, and then PhysicsComponent1 gets set to the bone information of PhysicsComponent2.

Am I doing something wrong? Or can you only have 1 PhysicsHandleComponent running at once?

Thanks in advance.

As soon as I posted this I found the solution, I’ll leave it here in case anyone has the same problem.

The initial way I was creating them was this:



PhysicsHandleComponent1 = PCIP.CreateDefaultSubobject<UPhysicsHandleComponent>(this, TEXT("PhysicsHandleComponent"));
PhysicsHandleComponent2 = PCIP.CreateDefaultSubobject<UPhysicsHandleComponent>(this, TEXT("PhysicsHandleComponent"));

And this is the fix, I didn’t set different names in the TEXT area, so it was updating the same component:


PhysicsHandleComponent1 = PCIP.CreateDefaultSubobject<UPhysicsHandleComponent>(this, TEXT("PhysicsHandleComponent"));
PhysicsHandleComponent2 = PCIP.CreateDefaultSubobject<UPhysicsHandleComponent>(this, TEXT("PhysicsHandleComponent2"));