# How to implement flexible, deformable shapes?

I'm making a top-down, 2D wargame that simulates large numbers of troops fighting. Instead of taking the Total war approach and modelling each soldier individually, I represent them as 1000-man formations that fight when TOUCHING an enemy.

Instead of using a square or circle collider, I'd rather these units have flexible, deformable shapes. Ex: a thin line, a thick wedge (see picture below). When units touch, they fight, and if the attacker is winning, physically pushes the defender back (and deforming their shape). It would be cool if units could have their shapes cut in two or snapped if a powerful attacker pushes through their lines.

This poses challenges of both collider shape AND visualization, and calculating touching borders and deformations.

Any suggestions how to implement this?

My current idea is to have each 1000-man unit actually have several smaller circle colliders and rigidbodies, and have the lead/central circle be connected to the others via hinge joints. But visualization is tricky, and relying too much on unity physics when combined with navagents is tricky.

• Flexible, deformable shapes controlled by physics are called "soft-bodies". As you probably know, Unity doesn't have built-in support for softbody physics, but you can probably find third-party solutions for softbody physics or deformations. I would not try to create softbody-like behavior using multiple rigidbodies connected by joints. Commented Apr 5 at 22:43
• Personally, I would recommend simplifying by having one army represented by several independent circular clusters of units that move and act together. You shouldn't need to use physics for anything beyond collision detection. Your idea would be so complex that you'd probably never finish it. Commented Apr 5 at 22:53
• That's a good idea, and probably what I'll end up doing (but will try using 10-100 boids to represent each unit) Commented Apr 8 at 16:46