Hello,
I am trying to figure out how to “attach” a character that has been ragdolled with the “Set All Bodies Below Simulate Physics” and “Set Simulate Physics” functions – to another Actor in the scene (such that the ragdolled character moves with the other character but still “hangs limp” like a ragdoll).
First I should ask, is it possible? If it is, how might I go about making it work?
I am currently able to successfully attach the actor to my other character’s socket, but only if the character being attached is NOT ragdolled (or under physics simulation I guess). What is it about the ragdolled character that makes attaching the actor not work?
I will provide the working code below (but only works if not ragdolled). I read on some other posts that when a character is ragdolled, it gets “detached” from it’s parent. And that you have to re-attach it somehow. But I don’t know what this means, or what functions I need to perform to re-attach it to the parent, or what the “parent” even is.
Here is the code I have so far, that works if the actor is not ragdolled:
void UMainCharacterController1::AttachActorToFootSocket1()
{
if (ActorToGrab1 != nullptr)
{
// Set the enemy/actor's movement mode to "None" or to "Flying", so that the ragdoll can freely move
// with the main character
UCharacterMovementComponent *MainCharacterMovementComponent1 = ActorToGrab1->FindComponentByClass<UCharacterMovementComponent>();
MainCharacterMovementComponent1->SetMovementMode(MOVE_Flying);
ActorToGrab1->AttachToActor(mainCharacterActor, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, false), "AttachEnemy1");
UE_LOG(LogTemp, Warning, TEXT("The AttachActorToFootSocket1 function was run and there IS an Actor!"));
}
else
{
UE_LOG(LogTemp, Warning, TEXT("The AttachActorToFootSocket1 function was run, but no Actor!"));
}
}
Thanks for any info.