Godot Version
Godot 4.3 stable
Question
So I followed this tutorial, and in it, there is a call during map generation (randomly creates maps) and it generates items.
At a later step, when you go to grab it off the ground, it calls item.get_parent().remove_child(item) to remove it from the map and put it into your inventory.
So I basically copied the code, used to generate the item at map creation, to create an item drop system for entities. I got no errors from generating the item, picking it up has no issues, and using the item, has no issues.
However, there is three problems I’ve noticed with this method. 1) The item generated is invisible on the ground. 2) If you try to drop the item from the inventory, the game crashes with an obtuse error. 3) If you go to the next floor and try to open the inventory, the game crashes with a different error.
Now, when I try to call an item created by the map, there is no issue with item.get_parent().remove_child(item). But when I try it with a monster drop, it crashes with an error. So I wanted to see what might be the issue so I did print(item.get_parent()) to see what the output was.
With a regular item its like Entity:Node#29128312319 or something. With a monster dropped item, its <Object#null>. Now when I go to create the item, it appears to acquire all the data that it should be getting, such as its texture, color/alpha value, so it should in theory be visible but it isn’t. It also has all the data for an equipment or a consumable, allowing you to use them like a normal map generated item, so clearly it received some important data.
So what would cause <Object#null> and how might I try to prevent it?
I’d post the code, but it looks like there is multiple godot scripts involved in generating the actual items, but can try to get it if you think it is important.
For now, I disabled the item drop system for monsters, so it doesn’t affect my game for now (as you still get items generated on the ground), but I do want an item drop system at some point.