Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing RigidBody2D mode propery doesn't work from inside Area2D body_entered signals #50876

Open
Tracked by #45334
DanielKinsman opened this issue Jul 26, 2021 · 3 comments

Comments

@DanielKinsman
Copy link
Contributor

DanielKinsman commented Jul 26, 2021

Godot version

3.3.2.stable.arch_linux

System information

arch linux

Issue description

Changing a RigidBody2D's mode property from rigid to static from inside an Area2D's body_entered signal doesn't appear to work. The property changes but the object keeps moving. Changing mode from a button press signal works fine. Using the CONNECT_DEFERRED flag also works. Perhaps mode shouldn't or can't be set from inside physics in which case this could be a just a documentation change?

Steps to reproduce

Run the minimal repro project, watch the logo fall into the area2d, change to static mode but keep on falling

Minimal reproduction project

rigid2dmodetest.zip

@Torguen
Copy link

Torguen commented Jul 26, 2021

I think you should use call_deferred because the effect of the change should not be immediate.

@DanielKinsman
Copy link
Contributor Author

What I should be doing is irrelevant. It shouldn't be possible to get the body into a state where it's mode is "static" but it is responding to gravity and other forces.

If setting it to static can't be made to work easily from this context, it should at least log an error, stay in rigid mode, and the documentation around mode should be updated.

@pouleyKetchoupp
Copy link
Contributor

There's already a logged error in this case that explains what to do instead:
body_set_mode: Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.

I'm marking this issue as documentation so a note can be added in mode and maybe other properties that are not allowed during a contact signal call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants