I have a question about timing of the queue_free()
function. Is the object freed immediately or is it queued to be freed at the earliest convenience?
I ask because in the Lightning script the queue_free()
function call is in the for loop. I would put it after the loop. My reasoning is that if the lightning collides with the terrain and bunny at the same time and the get_overlapping_bodies()
call returns the terrain before bunny in the list, the queue_free()
is called before Global.GameState.hurt()
can be called. This is only an issue if the free is immediate. It’s an edge case and doesn’t affect game play, but it other instances, could be important.
However, if the free is not immediate, we are queuing the free once for each object returned, which is just extra overhead for the garbage collector to look for an already freed object.