AddChild from blueprint not working

Hi!
Please help in solving creating widget problem.
I’m trying to create a system when enemy is spawning in the level automatically appear its life bar on the right side of the screen. For these purposes, I have created two widgets: the main widget which contains vertical box (always displays) and progress bar widget. In enemy blueprint should create life bar widget and add to Main widget as a child. But, this scheme is not working, there is nothing appears on the screen. What am I doing wrong?
Using UE 4.5

alt text

you cant use the created widget, you need to pass some element on the widget to the AddChild

I cant cast created widget, but it seems not working. I tried to create such structure When enemy spawns, it creates new life bar widget in which activates event construct in itself. But it not working. Please, what I’m doing wrong?


1)in your life widget give a name (lets say “someElement”) and make to be variable to the element you are going to add further to the container. It is not whole your widget, it’s f.i. a button or some container that contains the button, some textedit etc.
2)after creating an instance of the widget get those element - someElement - from it and pass it to the addChild

I tried to do like you said, but it not working. I attached video what is happening on my computer, to better understand.
Main idea: I have a planet system which can contain 4-9 planets. When game is starting there should display life bar of each planet on screen. [Video][1]

Hello Supreme,

I would like to try the easy solution first to make sure no possibilities are missed. Will you please check your anchor points. You may need to set your anchor points to the right side of the screen. I hope this helps.

Example:

Make it a great day

First put a breakpoint and verify that your addChild stuff is actually being executed.
Try to start from simple elements, like just a text box.
Once you find it’s ok with it, try warping your custom element with a size box: ue tends to squeeze elements to 0 height in containers.
Generally your bp looks as it should, same kind of work for me.

Alas, but it did not help.

Hello Supreme,

After going back and reading through the issue again, I realized that I had miss understood your problem. I have an example of how to show a health bar for each planet that may help you get started. I hope this helps.

Please note that any changes you need to make to the health bars will need to be done in the planet blueprint by pulling off of the variable that is used to represent your widget (in my case New var).

Example:

Planet Blueprint:

My Character Blueprint:

22265-widgetrefhelp2.png

Make it a great day

Thank you very much! I am very grateful to you! This option really works. It’s a pity that I cannot add one widget to another. It seems that such a possibility was pointed out in official documentation … But at least there is progress, we will work with what we have. Once again, thank you very much. You helped me a lot!