Constructing an objecting and giving it values

Howdy, I’m currently trying to create a menu that will allow my player to look at all the “abilities” they have. Abilities in this case are a lot more like weapons so they have individual stats, but they are components attached to the player.

My current strategy for making this menu has been:

Create the menu
On Initialized the menu looks at all the ability components and creates a widget I made representing an ability’s stats tab
Set the ability for that the stats tab is going to be displaying
The ability’s stats tab On Initialized will try to create another widget that just tracks one stat of the ability at a time

This seems fine in theory until in practice that On Initialized kicks in and just ruins everything as the ability for the tab has to get set after the On Initialized happens.

So I guess I have a couple questions:

  1. Is there a better way to do this, like entire thing?
  2. Is there some way to set a value while an object is constructing in Unreal blueprints?
  3. Is making a second function that just means “really on initialized” going to be the actual solution to my current problem?

Thank you to anyone who sees this and responds!

In your variable properties you can enable “Expose on spawn”, it should add corresponding pins to the SpawnActor / CreateWidget nodes to let you set variable values before BeginPlay / Initialized events are triggered.

image

image

1 Like