Variable Values for C++ and Blueprint

I understand the order of event for the game is C++ Constructor → BP Constructor then C++ BeginPlay() → BP BeginPlay().

Currently, I have variables in C++ which are marked EditDefaultsOnly and exposed to BP. If I set those values in BP but try and access them in the C++ constructor, it returns the initial value set in C++ (such as nullptr) NOT what was set in BP.

Right now I am trying to create / use UDataTable but the row name is set in BP (initialized in C++ as " ") and it never finds the row (UE_LOG shows it trying to find the row with ID " " ).​

When are the values set in BP readable in C++?

Hey Cetaurefie-

As you mentioned, the C++ constructor runs before blueprint construction. If you’re setting something inside the blueprint, the C++ constructor won’t know what is being set. You can try the PostEditChangedProperty() function as this is called when an actor is created / updated in the editor. Your best bet for ensuring that what is set in the blueprint is accessible in C++ would be to access the value in the C++ BeingPlay() function.

Cheers

Doug Wilson

I thought as much. I was trying to set the mesh of an actor from the datatable, but since its calling from in beginplay() it never shows the mesh when placed inside the editor. Is there a way around that? I’m just setting the mesh in BP instead of from the datatable for now.