Hello,
i try to change the ECollsionResponse of a custom TraceChannel for a specific Bone of my SkeletalMesh on runtime.
The idea is to make a specific bone clickable and all others bones not clickable.
The problem is, it seems like i cant set the CollsisionResponse on runtime for a specific bone, i can just change it for the whole SkeletalMesh.
this is my approach:
is created a custom TraceChannel “MyTraceChannel” in ProjectSettings->Collision,
this led to the following lines in “DefaultEngine.ini”:
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,Name="MyTraceChannel",DefaultResponse=ECR_Ignore,bTraceType=True,bStaticObject=False)
//...
GameTraceChannel1="MyTraceChannel"
looks good so far.
In my C+±Pawn-Class i set the CollisionResponse for all Bones to “ignore”, expect for the one I want to click by:
for (auto& Elem : MyMesh->GetPhysicsAsset()->BodySetupIndexMap)
{
MyMesh->GetBodyInstance(Elem.Key)->SetResponseToChannel(COLLISION_MYTRACECHANNEL, ECollisionResponse::ECR_Ignore);
if (GEngine)GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Cyan, FString::Printf(TEXT(" %s: ignore"), *Elem.Key.ToString()));
}
MyMesh->GetBodyInstance("MyBoneWithThisName")->SetResponseToChannel(COLLISION_MYTRACECHANNEL, ECollisionResponse::ECR_Block);
But this seems to have no effect.
If I set Collsion-Presets->CollisionResponses for MyMesh in Editor every Bone (when block is active) or no Bone (ignore is active, shown on image) is clickable. The runtime changes done in c++ have no effect.
Does anyone know a solution how to set the CollisionRespone for a specific Body on runtime?
Thanks,