godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.15k stars 97 forks source link

Add functions to apply forces and impulses on SoftBody nodes #1013

Open ctrlaltmilk opened 4 years ago

ctrlaltmilk commented 4 years ago

Describe the project you are working on:

I was seeing if I could make a controllable blob that could squish through tight spaces.

Describe the problem or limitation you are having in your project:

Without any way to apply forces to the blob, it's hard to get an accurate simulation of the movement.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:

These new functions would make the SoftBody easier to work with, and would mean more potential uses for this node type.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

The RigidBody node has apply_impulse() and apply_force() as well as central versions, so I propose adding those to the SoftBody as well.

If this enhancement will not be used often, can it be worked around with a few lines of script?:

I do not see any way to work around this issue.

Is there a reason why this should be core and not an add-on in the asset library?:

I believe it should be a core functionality of the SoftBody because it seems like a good fit for the node's purpose.

follower commented 4 years ago

As I understand it, until recently this functionality was not implemented in the underlying physics library.

I think these Bullet physic engine issues/PRs are relevant to this proposal:

If this is the case, then the Bullet physics library version included with Godot will need to be updated & then the new functionality exposed.

Updated:

In the interim it might be possible to attach the SoftBody to a RigidBody & apply the force to the rigid body? Possible related issues:

James103 commented 2 years ago

Ammo.js does have a way to apply forces on soft bodies, either on the full SoftBody or on a node-by-node basis: https://github.com/kripken/ammo.js/blob/79190a1f03845794b1bba1777f30037349967658/ammo.idl#L1059-L1060

Is it still possible to add apply_impulse and apply_force functions to the SoftBody node in Bullet (3.x) and Godot Physics (4.x)?

James103 commented 2 years ago

Current workaround for this proposal: Use a physics layer and an Area3D with a vary large collision shape. The Area3D is set to add "gravity" on a specific physics layer only, which is also used by the player's SoftBody. The direction of the added force is controlled by player input.

Limitations of the above workaround:

Calinou commented 2 years ago

See also https://github.com/godotengine/godot/pull/58717.