Getting bone name from child mesh

I am trying to create a particle effect on a gun. the gun is a child to the character, and I can’t seem to find out how to get the child within C++

if I make the bone available on the character it works, but for the gun it fails to find the bone name, how do I get the child mesh reference?

1 Like

I think you can use GetChildComponent from the mesh and cast the result to USkeletalMeshComponent

with the GetChildComponent doesn’t have the function GetSocketByName, how would I apply the socket name with the GetChildComponent?

1 Like

Once you casted it to USkeletalMeshComponent you should be able to call GetSkeletalMesh from it, and then from it you can call GetSocketByName

Sorry if it’s not correct, I’m answering from my phone relying on my memory only and it’s almost 1AM :sweat_smile:

unless I am missing something I have to set a socket with GetChildComponent. I can’t just create a pointer to the child component without a socket Which the only option is to get all of the sockets, and create an array of them to get the one I want, but this seems really poor.

USceneComponent * GetChildComponent
(
    int32 ChildIndex
) const

The GetChildComponent() function doesn’t need a socket, needs a index, you can set it to 0 assuming that it only has one child and you should be able to obtain a reference to the child component (then you have to cast it because it returns an object of class USceneComponent)