Overriding free() not working?

Godot Version

4.4

Question

I am making a game where the player and enemies have both have inventories, and I am trying to make a way for them to drop their items when they die, so I tried to override the free() call so that when one got deleted it would spawn the item drop, but it seems like it is never being called. How can I fix this?

The code

func free() -> void:
	*Drop the item*
	super()

I place break points throughout the section, but they never triggered making me think it was never called

Hi, I don’t think you can override the free function. Try overriding the _exit_tree function. The virtual functions that you are meant to be able to override all start with an underscore (_).

2 Likes

Thanks! I didnt realise that

1 Like

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