Here is a thread with a similar problem. The issue is that you are not using call_deferred()
when changing collision properties (like disabling hitboxes or destroying them) inside the collision handling method _on_ScareEvent_body_entered
The error is occurring because the physics engine is processing collissions, and you can't mess with the collision-related nodes that are part of that collision detection.
To solve it, make sure to destroy objects that have Area2D's actively being checked for collisions outside the event handler (e.g. call_deferred("queue_free")
and when disabling collision shapes/areas, I think you have to deferr the call as well.
How I handle this is I have a collision handling method that just appends all the collisions to a list, then on the physics step (inside _physics_process
) you can process the collisions, disable hitboxes, create hitboxes, etc. without having to use call_deferred