Edit a static mesh component

Hi All

I create a character which I have attached a static mesh component. I need to create on C++ side because the code will control if the mesh is visible or not

	const ConstructorHelpers::FObjectFinder<UStaticMesh> meshObj(TEXT("/Game/DemoRoom/Meshes/SM_UE4_Logo"));

	cubeTarget = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("CubeTarget"));
	cubeTarget->bEditableWhenInherited = true;
	cubeTarget->bSelectable = true;

So I’am seeing a UE4 Logo on my character but the size and location are not correct and I can’t edit at all with the blueprint .

Is there a way to do that ?

Thanks a lot

I don’t think you can do it the way you are, or at least it will be difficult.

This is how it should be done, you create the mesh on the actor, and then initialize it in the actor’s constructor class.
Then in game you’ll see the static mesh where you can set the mesh and all of it’s transform properties, etc.

UPROPERTY(VisibleDefaultsOnly) UStaticMeshComponent* cubeTarget;


cubeTarget= CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("cubeTarget"));


Hi NicolasB,

If I understood you right, you just want to change position and size of the object, if so then you just need to add

cubeTarget->SetRelativeLocation(FVector(0.f, 0.f, -500.f));  // change location
cubeTarget->SetRelativeScale3D(FVector(2.f, 1.f, 2.f));      // change size