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

Add support for controlling physics nodes' behavior when disabled #49834

Merged
merged 1 commit into from
Jun 30, 2021

Conversation

pouleyKetchoupp
Copy link
Contributor

@pouleyKetchoupp pouleyKetchoupp commented Jun 22, 2021

New property on_disable disable_mode in CollisionObject2D and CollisionObject3D to set different behaviors when processing is disabled:
Remove: remove from physics simulation
MakeStatic: change body mode to static (doesn't affect area and soft body)
KeepActive: do nothing

Same property on SoftBody3D with only Remove and KeepActive modes.

Extra change in Node:
Handle disable/enable node state with specific notifications, in order to differentiate global pause from disabled nodes.

Implements godotengine/godot-proposals#2843
Supersedes #46921

@Zireael07
Copy link
Contributor

Remove: remove from physics simulation

This needs more docs. What does "remove from simulation" mean? can they be readded?

@pouleyKetchoupp
Copy link
Contributor Author

Remove: remove from physics simulation

This needs more docs. What does "remove from simulation" mean? can they be readded?

They are automatically re-added when the node is enabled again. I'll update the doc to make it clear.

@@ -269,6 +269,9 @@
<member name="input_pickable" type="bool" setter="set_pickable" getter="is_pickable" default="true">
If [code]true[/code], this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one [code]collision_layer[/code] bit to be set.
</member>
<member name="on_disable" type="int" setter="set_on_disable" getter="get_on_disable" enum="CollisionObject2D.DisableMode" default="0">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't disable_mode be a clearer name? on_disable sounds like a signal callback.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I second disable_mode probably being best

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this name does sound better! Just pushed with this change.

New property disable_mode to set different behaviors:
Remove: remove from physics simulation
MakeStatic: change body mode to static (doesn't affect area and soft body)
KeepActive: do nothing

Extra change:
Handle disable/enable node state with specific notifications, in order
to differentiate global pause from disabled nodes.
@akien-mga akien-mga merged commit 915344f into godotengine:master Jun 30, 2021
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

4 participants