Hey,
I think I am missing something big here. I have C++ USceneComponent class called ULandVehicleWheel. It has to have visual mesh representation, but it cannot be derived from UStaticMeshComponent, because I don’t want to move component itself, only mesh. So it has public member variable exposed like this:
UPROPERTY(EditAnywhere)
UStaticMeshComponent *m_meshComponent;
In its constructor I create instance of it like this:
m_meshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("WheelMesh"));
m_meshComponent->SetupAttachment(this);
I have C++ Pawn class ALandVehicle. It has public member variable exposed like this.
UPROPERTY(EditAnywhere)
ULandVehicleWheel *m_FL;
In constructor of this class I call:
m_FL = CreateDefaultSubobject<ULandVehicleWheel>(TEXT("WHEEL"));
m_FL->SetupAttachment(m_body);
Now. Desired outcome is that in BP derived from ALandVehicle I could set mesh for ULandVehicleWheel’s UStaticMeshComponent. Which I can:
Thing is, after I press Compile on BP the mesh disappears, while still being assigned. It is only removed from the viewport:
Now, I know everytime I press Compile on BP, constructor for each C++ class gets called. So I guess I understand why it disappears, but I don’t understand the design behind this. I saw somewhere that I cannot use components inside other components, but it seemed to be because of lack of origin (for ActorComponents, not SceneComponents). So am I doing something I shouldn’t?
Thanks.