Blueprint assigned class member variables NULL during class constructor

Some values are only available after PostInitializeComponents(). Try overriding that method and do your logic there :slight_smile:

I have a member variable in my class:

	// Pointer to geometry pattern to apply
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = GeomProcess)
	UStaticMesh *	GeometryMesh;

In the Blueprint defaults, I can assign a mesh to that variable as I want. However if I put a breakpoint in the class constructor I find that the GeomeryMesh is unassigned and always NULL.

// Constructor
UGeomComponent::UGeomComponent(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
	// Process geometry
	if (GeometryMesh != NULL)

However if I later call a function on the class, from a Blueprint I notice that GeometryMesh is now assigned with the UStaticMesh * that I had set up in Blueprint.

How can I get access to the assigned member variables in the class constructor? Or perhaps I should be overloading another function and performing initialisation on member data at another point?

During constructor execution you can create new UObject (ex: PCIP.CreateDefaultSubobject(…), PCIP.CreateAbstractDefaultSubobject(…)) and save it’s pointer in uproperty.

To read value set in blueprint right after object construction, override this method: PostInitProperties.

Thank you, my component is a UActorComponent and so doesn’t have a PostInitialzieComponents() method. It does have an InitializeComponent() method which isn’t called.

In my component I can see bHasBeenInitialized is set to 0 when I call a function on it.

Looking, and fiddling, I find that OnComponentCreated() is called and it appears to have all data so I’ll put the initialisation there. Thanks for the lead.

You’re welcome :slight_smile:

Thank you! That’s what I need.