Read component properties in Construction Script?

  1. I created a new component containing a variable.
  2. Created a new blueprint.
  3. Added a component to my blueprint.
  4. My blueprint containing my component is placed on the scene.
  5. On the stage, I changed the values of the variable, in the component inside the bluetooth.
  6. In blueprint on the Construction Script, I read the value of the variable from the component.

I expect to get the value of the variable entered on the scene (MyVar=10)
I get the default value. (MyVar=0)

Tell me how to fix this problem?


3.jpg

1 Like

When NPC is constructed it doesn’t have the component yet, I guess. Which makes sense, its components cannot be there before it.
You have to wait, aka:
EventBeginPlay>>get MyVar.

what to do if I need to execute logic before EventBeginPlay? (Level Streaming)

I was wrong, after testing it, you can manipulate component variable in the construction script, but PrintString won’t work.

So, it really depeends what you wanna achieve…

Here what I tested:


I’ve checked with a PrintString in BeginPlay, ChildVar was set.

You can get the values from the component, but customizing its variables from the editor will not result in the changes being reflected immediately. You will have to start an instance of the game to make that happen.

If you want to reflect the changes in the editor itself, I believe you have to update the variable manually through the construction script of the owning actor.

I am also hitting this.

For my use case I’m trying to hide or show a billboard component based on the values of a different component (basically as an in-editor warning). Anyone know of a way to do that kind of check/update before BeginPlay is called?