extends CharacterBody2D
var aStarGrid: AStarGrid2D
func _ready():
aStarGrid = AStarGrid2D.new()
After that I use aStarGrid for something.
The CharacterBody2D is the player.gd script.
At certain point I queue_free() the CharacterBody2D so i can create new level and then create player again by instantiating.
My question is - is the aStarGrid also destroyed/freed at the point of queue_free() if it is part of the player.gd script like above? Or it must be explicitly freed?
Is there a debugger where I can see which variables are still instantiated similar to “Remote” tab?
I can see it is RefCounted so my assumption it would be free automatically, but I am not sure.
I’ve never heard of AStarGrid2D (it’s not in the list of controls or nodes), but if it’s parented to the player, and the player is properly destroyed, it should be cleared.
If you want to know, get to the state after the player has been destroyed while the game is playing and check the Remote section of the IDE and check if the player and its children are still there.
It inherits “RefCounted” it will be destroyed when nothing has a reference to it. Player is destroyed, one less reference, if nothing else references this object then it will be destroyed with the player.