Announcement

Collapse
No announcement yet.

Read component properties in Construction Script?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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?

    Click image for larger version  Name:	1.PNG Views:	0 Size:	275.6 KB ID:	1679542

    Click image for larger version  Name:	2.PNG Views:	0 Size:	55.8 KB ID:	1679541
    Click image for larger version  Name:	3.jpg Views:	0 Size:	37.4 KB ID:	1679543

    #2
    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.
    WIP ShootOut - 3rdPerson ARPG

    Comment


      #3
      Originally posted by silik1 View Post
      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)

      Comment


        #4
        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:
        Click image for larger version

Name:	ChildActor.png
Views:	528
Size:	60.0 KB
ID:	1679675
        I've checked with a PrintString in BeginPlay, ChildVar was set.
        WIP ShootOut - 3rdPerson ARPG

        Comment


          #5
          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.
          Unreal Possibilities
          Wave Spawning System | Tower Defense Starter Kit | Grid Creation Systems

          Comment


            #6
            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?

            Comment

            Working...
            X