The collision is not disabled

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Simon

i try to make a platformer with some desappearing platform that when my player enter the platform area play an animation, sprite become invisible and collision become disabled. This is my code:

func _on_Area2D_area_entered(area):
   $Sprite.visible = false
   $CollisionShape2D.disabled = true

But when my player jump on the platform the collision it’s not disabled and this error message arrives:
body_set_shape_disabled: Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.
How can i do this?

:bust_in_silhouette: Reply From: jgodfrey

Try replacing this:

$CollisionShape2D.disabled = true

with this…

$CollisionShape2D.set_deferred("disabled", true)

Thanks! It work!

Simon | 2020-10-04 14:16