+1 vote

I'm trying to set the monitorable property of the instanced Area2D scene as false via script after the other Area2D enters it, but it's not working, it's always says it is true. The rest of the code works as expected.

What am I doing wrong here ?

I've tried:

self.monitorable = false


in Engine by (187 points)

2 Answers

+6 votes
Best answer

I tried this too printing the monitorable property every frame, and you can actually see what's happening in the system console:

ERROR: Function blocked during in/out signal. Use set_deferred("monitorable", true/false).
   At: scene/2d/area_2d.cpp:424

It's a bit unintuitive, but the reason monitorable cannot be changed from within the signal handler is because the area is currently doing the monitoring, that state cannot be changed until it's done doing it.
So you may want to do this instead:

set_deferred("monitorable", false) 
by (29,088 points)
selected by

Thanks a lot, man!

+2 votes

maybe try to use


otherwise I do not know what's wrong

Edit: Zylann's answer is better. Idk what is wrong with me, set_deferred is way better

by (43 points)
edited by
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.