Godot Version
4.2.2
Question
Just want to document this as I’m not sure if it’s a bug or I just misunderstand something.
Disabling an Area2D, and it’s CollisionShape in the SAME FRAME can break the collision. I made a demonstration video:
Fascinating: Some people report the same problem BUT the outcome is, that the collisions are now reported all the time (Disabling process of PhysicsBody2D and containing Area2D on same frame will make area register body as entered forever · Issue #76219 · godotengine/godot · GitHub) while in my case, NO collision is reported anymore.
TLDR;
This may break the collision:
# Both NOT deferred (not a good idea in general!)
%CollisionShape2D.disabled = true
%enemy.process_mode = Node.PROCESS_MODE_DISABLED
# Both deferred
%CollisionShape2D.set_deferred("disabled", true)
%enemy.set_deferred("process_mode", Node.PROCESS_MODE_DISABLED)
This works:
# Only setting collision is deferred
%CollisionShape2D.set_deferred("disabled", true)
%enemy.set_process(false)