I want my character to die and disappear when hitting an object (such as lava). How can I do it
How can i destroy an object ?
In addition, I want the deleted object to be deleted from the database and not to weigh on the system.
Welcome to the forums @AEShooter!
It depends on what type of object you have, to be honest.
If you are wanting to delete a node, you can use the queue_free
function to delete the node (example: $NodeNameHere.queue_free()
). Given you are saying you want the player to disappear, I am guessing you are working with nodes, so using queue_free
should work fine.
Godot does not have a garbage collector, but it does have a reference counting system. When there is no reference to something, Godot will automatically free it (simplifying a bit, but in the majority of cases this holds true).
For deleting in the database, it depends on the database in question and how the data is stored. Generally though, you just want to call something like database.remove(player_node)
before calling player_node.queue_free()
. I would suggesting looking at the API for the database you are using, as there should be a function that removes an element using either a key or value, which is what you can use to remove the object from the database.