0 votes

Hey. I created particles with physics (they are rigid bodies) and I added an AnimationPlayer node to queuefree() them after a few seconds. I added the queuefree function in a script running on each rigid body particle.
The problem is that, when the AnimationPlayer runs the queuefree function after a few seconds, the game crashes and I get a Stack Overflow (Stack Size: 1024) error message. Do I have to manually resize the stack or is there another way to queuefree scenes via the animation player?

Scene structure:

---AnimationPlayer (calling queue_free())
---VisibilityNotifier2D (to remove when it's outside of the window)


func queue_free():


Stack Overflow (Stack Size: 1024)

in Engine by (29 points)

1 Answer

+2 votes
Best answer

The code:

func queue_free():

is causing the stack overflow error by recursively calling itself, which pushes a frame onto the stack, until there is no more allocated space for new stack frames: the overflow error.

The Fix

Remove the code you have posted. queue_free() is defined on Node. Just call the queue_free() function on the target node you want to free.

by (106 points)
selected by

Thanks for the reply, but I already tried calling queuefree() from the AnimationPlayer itself by not including it into the script, so it would call the default queuefree() function from godot, which didn't work for me.

Sounds like the cause of your issue is somewhere else. Try creating a MCVE to post. You may also identify the cause in the process.

I tried removing the queuefree() call from the AnimationPlayer and instead used a Timer which queuefree()s the parent node on timeout. It works now.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.