Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing overlapping Area2Ds with remove_child() causes errors #7507

Closed
pwnSquirrel opened this issue Jan 12, 2017 · 0 comments
Closed

Removing overlapping Area2Ds with remove_child() causes errors #7507

pwnSquirrel opened this issue Jan 12, 2017 · 0 comments

Comments

@pwnSquirrel
Copy link
Contributor

pwnSquirrel commented Jan 12, 2017

Operating system or device - Godot version:
Arch linux 64 - 2.2 branch

Issue description (what happened, and what was expected):

  1. When you have an Area2D and another Area2D or a PhysicsBody overlapping and set that they report collisions to each other, and you remove the Area2D from the tree (with remove_child()), you get errors like

ERROR: _body_inout: Condition ' !body_in && !E ' is true ...
or
ERROR: _body_inout: Condition ' !area_in && !E ' is true ...

call_deferred("remove_child", child) does NOT work here. It seems that they try to report another collider leaving the area although they are already removed from the scene.
The only ways for me to fix that were to use set_monitoring_enabled() in _enter_tree and _exit_tree or set them to different layers/masks (which is not a solution, they have to collide for gameplay reasons).
I already made a fix for that, using the monitoring solution from above (which I will make a pull request for as soon as the second problem is solved).

  1. When having multiple overlapping Area2Ds (and optionally PhysicsBodies) as children of one parent node in the scene, removing this parent node from the scene with remove_child() without freeing it and readding it after that will cause errors:

Condition ' !E ' is true
and in some cases also

Signal enter/exit_tree already connected to given method _area_enter_tree in that object.

All of those are thrown in area_2d.cpp when re-adding the Area2ds to the scene. So for some reason the connections aren't removed when removing the parent node is removed. But I'm still trying to figure out what causes the first error. And what is even weirder, if you make the Area2D's not overlap anymore after the errors have been thrown and you redo the whole thing, more errors are thrown although they should not be reporting collisiosn to each other anymore.
call_deferred() doesn't work here either.

I'm trying to fix this right now, if anyone has any hints regarding that, that would be helpful.
None of those problems occur if you just queue_free() them and reinstance them, but I like to keep my player object and my levels (that are just instanced children of a parent world node whichs has the UI and stuff) instanced when switching them, so they are in the same state as before when they get reloaded into the world.

Steps to reproduce:

  1. bug: Make two or more Area2Ds, let them overlap. Remove one of them using remove_child()
  2. bug: Make two or more Area2Ds as children of a parent node, let them overlap. Remove and re-add the parent node with a script (this will likely also cause the 1. bug)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants