Can you give an example of the proper accessor? Because after further testing, I discovered my current code actually places the character I wish to attach to the other character’s socket at the correct place (once), but then the character simply falls to the ground, and it doesn’t move with my main character at all (i.e. doesn’t stay with the socket location at all).
I’m not sure how to get the “other character” to NOT fall to the ground (it’s a ragdolled character). I want it to attach to the socket, and stay attached.
I’ve tried changing the other ragdolled character’s movement mode to “Flying”, and to “None”. I’ve also tried to make sure the physics collision channels on both actors do not collide. Neither of those worked. Maybe I need to turn off gravity on the ragdolled character somehow?
Here is my current code:
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, true), "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!"));
}
}