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?

A bit late → Call a Custom event from the Construction script → Add a “delay until next tick” → do your construction stuff.

:light_bulb: Recommended approach (used in many games)

Instead of relying on blocking collision, use a Trigger Volume (Box/Sphere Overlap) and handle the behavior manually:

1. Detect entry into boundary

  • Place a larger invisible volume where the “soft wall” starts.

  • Use OnComponentBeginOverlap to detect when the player enters it.

2. Gradually reduce player control

  • As the player gets closer to the edge, scale down their input or velocity.

  • For example:

    • Map distance → speed multiplier (1 → 0)

    • This creates that “pushing against resistance” feel
      :backhand_index_pointing_right: This is a known technique: mapping distance to movement limits instead of stopping instantly (Epic Developer Community Forums)

3. Apply opposite force (rubber band)

  • When inside the volume, apply a force or movement offset back toward the center:

    • Direction = (center − player position)

    • Strength increases the deeper they go

4. Release behavior

  • When player stops pushing, the force naturally pulls them back → gives that elastic feel

:brain: Alternative (simpler Blueprint logic)

A very common pattern suggested by UE devs:

  • First phase: slow player to a stop (~1 second)

  • Second phase: apply increasing force pushing them back

This creates a smooth 2–3 second interaction instead of a hard stop (Epic Developer Community Forums)


:gear: Implementation tips (important)

  • :cross_mark: Avoid pure blocking volumes → causes your “stuck” glitch

  • :white_check_mark: Use overlap + manual velocity control

  • :white_check_mark: Modify:

    • Max Fly Speed

    • or directly scale input axis

    • or use Add Force / Add Movement Input in reverse direction

  • :white_check_mark: Use a falloff curve (Float Curve asset) for smoothness

  • :white_check_mark: Clamp max pushback force so it doesn’t feel jerky


:video_game: Bonus: “Star Fox feel”

For that classic Star Fox boundary:

  • Use a camera-centered box

  • Always push player toward screen center (not world center)

  • Add slight camera shake or tilt when pushing → sells the effect


:puzzle_piece: TL;DR

  • No built-in UE5 feature for this

  • Don’t use hard collision

  • Use:
    Overlap Volume + distance-based slowdown + reverse force

  • Think of it as a soft constraint field, not a wall