[Blueprints]Adding child to widget after removing previous child not working?

Hello!

In my inventory system, I’m dynamically creating items by using “Create Widget” function and then placing them in my grid using “Add child”.
My layout:

139458-przechwytywanie.jpg

  • Right side: inventory grid
  • Left side: Current equipment

You can equip every item by clicking action button (not visible here). I found that if you want to move existing widget (in my case, item in grid) to another widget (eg. helmet tile), you can call AddChild function.

Problem:

When I pick up an item, it shows in first tile as expected. I can also move my widget to equipment.

What I can not understand is where I use item (it’s moved to EQ) and first tile in grid is empty again, I pick up another item and… it doesn’t show up. I double checked everything:

  • Item widget is properly created, not null.
  • There is no child in first or any other tile

Question:
Why when I want to add a child widget to border after removing previous child, it is invisible (I also cannot interact with it)?

Cheers.

Give my answer a go first, and if that doesn’t work then, just for debugging purposes, try to do this without collecting the items in game.

What I mean by this is in IG, add a 1 second delay to the begin node to spawn in an item, then another 1 second delay to remove from parent, then yet another second before adding a new one.

If that works, then, instead of removing from parent, equip it into EQ, then carry on with adding the new item into IG.

Also try adding a different item. If its a sword the first pick up, try picking up a shield the second time.

Based on what happens we can take further actions.

Try copying the original item into a variable name something like copiedItem , then removing the original from parent.
After that, add the new copiedItem into EQ.

What might be happening is there is a reference being left behind in the grid when it is moved.

Since this is exactly what I was saying to do, can you upvote my answer and mark it as accepted?

Still nothing.

I think it is worth mentioning that CopiedItem is a widget with statistics struct

I found something. When I create and then delete some item in inventory when the widget is closed (eg. through level blueprint) , everything works!

Based on my previous answers, I came up with a solution:

Still, I don’t know the reason for such a strange behaviour.