Adding a widget component during runtime isn't working

Hi,

Here’s my problem, I’m trying to add a widget component at runtime to an actor blueprint.
So what I do is add the node “Add Widget component” then I need to change the widget class so I can choose the one I want.

So I added a “Construct Object from Class” node and in there select the thing I want. But it shows nothing.
I tried setting the world location, scale and stuff to be sure it’s not somewhere I can’t see or too small etc but still the same.

I tried with a niagara particle system and it works flawlessly, so I assume I’m not doing things right for the widget one.

Thanks.

Hello @GoSsS ,

When you want to create a widget, usually we use “Create Widget” node. after then, don’t forget to add it to the viewport to show it.

Maybe you can try this

That was a good idea but unfortunately it’s not working when adding this node either :frowning:

Don’t use both. A component maintains widget lifecycle automatically.

  • either have a component:

  • or add a widget:

image

If you do both, you’ll have 2 widgets.


That was a good idea but unfortunately it’s not working when adding this node either

If what @ImAGoodSpoon1 suggests isn’t working, then there is something fundamentally wrong with the setup you’re using. To figure that one out, we’d need to know more, though.


If you want to swap out component’s widgets, you could try:


And finally, be mindful of which node you’re using:

  • this is for user widgets:

image

  • this is for objects and can construct native widgets:

image

Thanks Everynone for your explanation !!

The thing I wasn’t doing was setting the widget :smiley: like you did there :
image

That was obvious but I missed it :smiley:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.