How to attach a mesh to an actors socket?

Hi,

I am trying to attach a Static Mesh of a weapon to my Actor characters socket.



ASCharacter* Pawn = Cast<ASCharacter>(InstigatorPawn);
if (Pawn)
{
USkeletalMeshComponent *Character = Pawn->GetMesh();
MeshComp->AttachTo(Character, "Weapon", EAttachLocation::SnapToTarget);
}


Instead of attaching it to the socket, when i go to pick up the weapon i placed in game it falls back on the ground in a different location.

It sounds like the static mesh in question still has physics enabled.
If so, make sure to disable that first.

Otherwise, need more information :slight_smile:

@Kris

How do i disable the physics of the static mesh?

Believe me there is nothing more to it. Im just trying to Attach a static mesh to an actors socket.

Update:

@Kris ty. I figured it out.

MeshComp->SetSimulatePhysics(false); // Fixes Issue of not attaching
MeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision); // Fixes issue of weird movement after attaching mesh.