I have a group which keep track of items in the inventory of my game. When I click an item in the inventory, I want to remove it from the inventory group, hide the inventory group, and make the selected item follow the cursor for use.
Before Removal
console.log(inventoryGroup.children.length); // returns 2
console.log(inventoryGroup.children[1]); // returns item object
console.log(inventoryGroup.children); // returns array of 2 items
inventoryGroup.remove(item);
after removal
console.log(inventoryGroup.children.length); // returns 1
console.log(inventoryGroup.children[1]); // returns undefined
console.log(inventoryGroup.children); // returns array of 2 items
After calling remove, the item has been successfully removed from the group, but the item is still in the children array of the group. So when I make inventoryGroup.visible = false, the item also disappears.
How do I actually fully remove this item from the group without it staying as a child of the group?