The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

I'm following an example project by packt.com, and I'm having trouble with the collision detection and signal emittion.

The Main Scene contains a Player Scene, and the Coin scene is added in the inspector by adding

   export (PackedScene) Coin

in the MainScene script, for "cloning". The Player scene when enters any instantiated coin scene, areashapeentered is detected, on the connected function in Player script the area that enters is filtered by group, if the area is "coin" group, the area's collision is disabled, the area's node is queue to end after a tween is played, and a signal is emitted for the score to be increased in the MainScene script, but it seems the collision fires all this twice. To anyone interested helping me with my mistake the project can be downloaded here: https://we.tl/t-fzKrglj3x5

Thanks

in Engine by (29 points)

1 Answer

+3 votes
Best answer

If you look at the "Errors" tab as you run into a coin, you'll see this:

area_set_shape_disabled: Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.

To fix it, in the coin's pickup() method, try changing this:

$Collision.disabled = true

To this:

$Collision.set_deferred("disabled", true)
by (22,674 points)
selected 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.