0 votes

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?

in Engine by (55 points)

1 Answer

+1 vote
Best answer

Try replacing this:

$CollisionShape2D.disabled = true

with this...

$CollisionShape2D.set_deferred("disabled", true)
by (14,952 points)
selected by

Thanks! It work!

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.