I have a weapon C++ class which contains the logic for each weapon. There are multiple weapons that a player can posses during the game, so each new weapon is a blueprint class that inherits from the weapon C++ class. I’m currently trying to attach an item (an item that is only for looks only) which is a static mesh to a weapon that the player posses. This static mesh will be different for each of the blueprinted weapons.
I have the following public variable to hold the static mesh for each weapon:
UPROPERTY(EditDefaultsOnly)
UStaticMesh* CosmeticItem;
I have a socket in the skeleton hierarchy of the weapon where I would like to place this static mesh. This is also held within a variable (StaticItemAttachPoint) in the weapon class. The weapon is being attached to the 1st person pawn mesh via a socket (AttachPoint) outlined by the following line of code:
Mesh1P->AttachToComponent(PawnMesh1p, FAttachmentTransformRules::KeepRelativeTransform, AttachPoint);
Ideally, I would like to first attach the cosmetic static mesh item to the weapon which will then get attached to the 1st person pawn mesh. Something similar to this:
CosmeticItem->AttachToComponent(Mesh1P, FAttachmentTransformRules::KeepRelativeTransform, StaticItemAttachPoint);
Mesh1P->AttachToComponent(PawnMesh1p, FAttachmentTransformRules::KeepRelativeTransform, AttachPoint);
Unfortunately, looking through the API on UStaticMesh there doesn’t appear to be any sort of attach type functions. Which leads me to wonder if I’m approaching this problem in the wrong way.