Hi,
I have tested this on simple c++ flying template.
I have created a custom static mesh component. This is how constructor looks like:
UMyStaticMeshComponent::UMyStaticMeshComponent(const FObjectInitializer& ObjectInitializer)
:Super(ObjectInitializer)
{
struct FConstructorStatics
{
ConstructorHelpers::FObjectFinderOptional<UStaticMesh> Mesh;
FConstructorStatics()
: Mesh(TEXT("/Game/StarterContent/Shapes/Shape_NarrowCapsule.Shape_NarrowCapsule"))
{
}
};
static FConstructorStatics ConstructorStatics;
SetStaticMesh(ConstructorStatics.Mesh.Get());
SetCollisionEnabled(ECollisionEnabled::NoCollision);
}
This is how I created it inside the constructor of a pawn:
TestMesh = CreateDefaultSubobject<UMyStaticMeshComponent>(TEXT("TestMesh"));
If I don’t attach TestMesh to RootComponent, then the TestMesh is only visible in clients. If I attach it, it is working fine (visible in both server and client).
TestMesh->AttachTo(RootComponent);
Why is this happening that it is only visible in clients. Is this a bug? What should be the correct behaviour.
Thanks
Anicka