I have a component which is dynamically spawned during the game and attached to a pawn (UMiningComponent). That part works fine. However what i’m trying to do is to then add an another component with a mesh to it (Component B). Unfortunately when I do this the mesh isn’t visible. Can someone see what I’m doing wrong?
.h
class SPACECOOP_API UMiningComponent : public UStaticMeshComponent
{
GENERATED_BODY()
UMiningComponent(const FObjectInitializer& ObjectInitializer);
public:
/** Static Mesh*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Custom)
UStaticMeshComponent* MiningActiveMesh;
};
.cpp
UMiningComponent::UMiningComponent(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
MiningActiveMesh = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("MiningMesh"));
MiningActiveMesh->AttachTo(this);
MiningActiveMesh->bVisible = true;
}