BP default value is not being passed to the C++ constructor. I want to spawn by ObjectInitializer.CreateDefaultSubobject in the blueprint editor from an array, but it seems that c++ constructor fires first before the BP default is read, so there’s nothing being spawned in the editor.
So is there a way to pass BP default value before C++ contructor fires, like a deffered spawn.
My fix right now is using the BP constructor, but pawning objects there doesn’t reference it to the BP default, so I can’t really edit the value of those spawned object, this is only good for passing value like a float to the constructor. Unlike the one spawned by ObjectInitializer.CreateDefaultSubobject I can edit their values but as the first problem goes I can’t dynamically spawn object from an array.
You are misunderstanding how the engine works;
Your Blueprint is not your C++ class. Therefore you shouldn’t expect your C++ object to interact with a Blueprint’s (fake) constructor. The BP constructor function was created to emulate the C++ CDO behaviour, but it is not really an object constructor.
I know it’s labeled introduction, but it shows the communication between C++ and Blueprints. If this communication between C++ and Blueprints is not your problem, please go ahead and give more details, so we can help <3.
@Ninjin BP default as in the UPROPERTY. Thanks, what I needed was the PostEditChangeProperty. Though there’s another problem, the value edited in the BP default is not being passed to runtime
With a great deal of extra supporting code. I’m not saying it’s not feasible in theory - pretty sure I recall someone from Epic saying it was on the wanted list years ago. But currently the engine doesn’t let you do this in response to values in blueprint properties.
It’s not quite the same thing anyway - ‘Add Component’ is essentially changing the structure of the blueprint class itself; what you’re after would require changing the structure of the class in response to changes to the value of a property in the CDO instance of that class.
// Sets default values
AItemBase::AItemBase()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;