Trying to get some physical animation when reacting to hits. Tried the following C++ in the character class:
// constructor
PhysicalAnimComp = CreateDefaultSubobject<UPhysicalAnimationComponent>(TEXT("Physical Animation Component"));
PhysicalAnimComp->SetSkeletalMeshComponent(CharacterMesh);
PhysicalAnimComp->ApplyPhysicalAnimationProfileBelow(TEXT("pelvis"), TEXT("HitReact"), false, false);
// separate function
if (CharacterMesh)
{
// ensure root not hit
if (HitBoneName == TEXT("pelvis")) HitBoneName = TEXT("spine_01");
CharacterMesh->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
CharacterMesh->SetAllBodiesBelowSimulatePhysics(HitBoneName, false, true);
CharacterMesh->SetAllBodiesBelowPhysicsBlendWeight(HitBoneName, .5);
CharacterMesh->AddImpulse(HitVelocity);
}
Also tried the following in BPs:
In both cases, I get the error "mesh (bone name) needs to have physics enabled to add impulse.
I have a functional physics asset set on the character mesh and a standard collision capsule with collision set to physics only.
Any help much appreciated.