// Hi, this should work. Copy and paste below into your constructor. Hope it helps.
/** Your header file should look like this */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Weapon")
class UStaticMeshComponent* WeaponMesh;
/** include these headers in your cpp file */
#include "Components/StaticMeshComponent.h"
#include "UObject/ConstructorHelpers.h"
#include "Engine/StaticMesh.h"
/** Add this to your default constructor in cpp file */
// set the mesh
WeaponMesh = CreateDefaultSubobject(TEXT("WEAPON"));
// attach to root component
WeaponMesh->SetupAttachment(GetRootComponent());
// set path for static mesh. Check path of mesh in content browser.
static ConstructorHelpers::FObjectFinder Shotgun(TEXT("StaticMesh'/Game/shotgun.shotgun'"));
// check if path is valid. Check path of mesh in content browser.
if (Shotgun.Succeeded())
{
// mesh = valid path
WeaponMesh->SetStaticMesh(Shotgun.Object);
// set relative location of mesh
WeaponMesh->SetRelativeLocation(FVector(60.f, 23.f, -21.f));
}