How can I find the location of a socket through c++?

Is there a way to know the location of a socket on my character through the help of c++.

Suppose I have a socket on my characters hand. And I want to spawn a effect in the position of that socket, is there a way to do so?

You can get the location with GetSocketLocation()

You can also attach the ParticleSystem at the socket by simply providing the name of the socket in the AttachTo() method.

How do I use it?

Something like this?

SocketLocation = USceneComponent::GetSocketLocation("FirePoint");

FirePoint is the name of the socket

FVector socketLocation = Mesh->GetSocketLocation(“FirePoint”);
Where Mesh is your USkeletalMesh / USkeletalMeshComponent.

Ok worked. Thanks…

Are all USceneComponents are used in this way?

How do you mean?

Like other function using USceneComponents need to use its mesh as an pointer.

Means if I am using USceneComponent::AttachTo() to attach a particle emitter,
I should write it like

Particle->Attachto(Mesh, "FirePoint", KeepRelativeOffset);

Something like this?

Yes, but Mesh in this case is defined in the ACharacter class and is a USkeletalMesh. You can see it here in the list of variables:

The name Mesh would be replaced with the name of the variable holding whatever component you wish to attach the Particle to (in your example).

Also there’s a difference between USkeletalMesh and USkeletalMeshComponent.
USkeletalMesh derives from UObject which means it’s not a USceneComponent.

There is also this option.

Link to other similar question

Is this only for particle systems or could this work for projectiles as well?