I'm trying to make custom 2D softbody physics that can interact with other Unity colliders.

My starting point was to implement a custom spring joint capable of connecting two entities ("particle") together. With these joints and with 4 particles I made a simple rectangle. The 4 particles are created inside a GameObject used as a container, to which I applied the RigidBody2D and PolygonCollider2D components. So the displacement of the particles is relative to the container.

If I apply forces directly to the particles the figure deforms correctly and works quite well, but the problem is that I don't know how to get the forces directly from the collider or the rigid body.

What I would need is to deduce from the collisions the forces to be applied to the particles, and at the same time keep the standard behavior of the collision.

Do you have any suggestions on this?

  • \$\begingroup\$ Myself, I usually make it so the particles are the collider/body. Each one individually handles its collisions, and the parent object is then a visualization of the particle swarm, rather than having a collider/body of its own. \$\endgroup\$ – DMGregory Jan 24 at 16:57
  • \$\begingroup\$ But then you need a lot of particles to well cover entirely the shape surface, is it correct? \$\endgroup\$ – blow Jan 24 at 17:56
  • \$\begingroup\$ Not necessarily. The most common way I've seen softbody physics being used is with particles being linked together, into the outline of whatever shape is needed, and wrapping a mesh around those colliders. \$\endgroup\$ – OKprogrammer Jan 27 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.