I would like to be able to move a specific physics body at runtime, preferably through blueprint.
I created a C++ function to do this.
In SkeletalMeshComponent.h, add this:
/** Set specific physics body transform to a new world transform */
UFUNCTION(BlueprintCallable, Category = "Components|SkeletalMesh")
void SetNewPhysicsBodyTransform(const FName BoneName, const FTransform& NewTransform, ETeleportType Teleport, bool bAutoWake);
Then in SkeletalMeshComponent.cpp, add this:
void USkeletalMeshComponent::SetNewPhysicsBodyTransform(const FName BoneName, const FTransform& NewTransform, ETeleportType Teleport, bool bAutoWake)
{
FBodyInstance* BI = GetBodyInstance(BoneName);
if (BI)
{
BI->SetBodyTransform(NewTransform, Teleport, bAutoWake);
}
}
Turns out there was already a function to do this in C++ inside the BodyInstance, so I just needed to expose that function to the SkeletalMesh and to blueprint.
You can now call it using: