Download

UPROPERTY help

Hello, i need help with setting my UPROPERTY. The thing is: I created a Button (C++ class) that is (should) moving one StaticMeshComponent of an Actor (eg. Machine (C++ class). This machine class has also Blueprint class so I can easily setup my static meshes (created in C++ by CreateDefaultSubobject<UStaticMeshComponent> of Machine class. So I drag my Machine to the world, I drag my button to the world and then I want to set in Button Details which StaticMeshComponent of Machine it will be moving. I made UPROPERTY() AMachine MyMachine = nullptr. But it allows only to choose Actor of AMachine class. The idea is to two UPROPERTIES (firstly i choose an actor class and in the second uproperty I can choose this actor components). It this is not possible it can be just one UPROPERTY where I can choose from all components of all Actors(?). Hierarchy of my AMachine is:
AMachine


StaticMeshComponent (Root)
…StaticMeshComponent
…StaticMeshComponent
…StaticMeshComponent
​​​​​​​…StaticMeshComponent

If someone knows something, any help will be appreciated.
I can also post SS or paste Code. Please ask if something is not clear.

I’m not entirely sure what you mean by this, but it sounds like you are wanting a component in your C++ class that you can change in your blueprint.

To setup a UStaticMeshComponent, you will need:

.h
/** Static mesh /
UPROPERTY(VisibleAnywhere)
UStaticMeshComponent
StaticMeshComponent;

.cpp
StaticMeshComponent= CreateDefaultSubobject<UStaticMeshComponent>(TEXT(“Static Mesh Component”));

Then in the blueprint, you will be able to select a static mesh component.