How to retrieve actor(s) attached to a socket?

Is it possible to retrieve all actors attached to a specific socket?
It seems that the only thing exposed is the transform’s socket.

And on the other way, is it possible to know if an actor is attached to a socket and know the socket name?
Currently I use GetAttachedParent to see if an actor is attached to a socket but there is no information on the socket itself.

Yes, you can.

 //Loop through all the sockets of the mesh
     for (auto SceneComp : GetMesh()->AttachChildren)
     {
         GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, SceneComp->AttachSocketName.ToString());
 
 //We want to get all children of a specific socket name
         if (SceneComp->AttachSocketName == this->HolsterGrenadeWeaponSocketName)
         {
 //Now we found the socket that we want, so lets loop though all the children of this socket and print out each child's name
             for (auto x : GetMesh()->AttachChildren)
             {
                 // we found an actor!
                 GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, x->GetFullName());
             }
         }
     }

For those using Blueprint, you can achieve this by calling “Get Children Components” on the skeletal mesh, then iterating through the children and comparing their attached socket name to your desired socket name. From there, you need to cast the child component into the type you are expecting.

4 Likes