How to get play character's skeletal mesh and attach a hat to it?

  1. Create an event called OnHatPickup(AStaticMeshComponent* HatSM) on your player character

  2. Call that inside the OnOverlapBegin function in your AHatPickup class

  3. Inside the OnHatPickup function in your player class type:

    if (HatSM)
    {
    	HatSM->AttachToComponent(GetMesh(), FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true), FName("headSocket"));
    }