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.

enter image description here IMAGE https://i.gyazo.com/74187a7724e2b1ba6d089452cd5f5959.png

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.

  • \$\begingroup\$ 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. \$\endgroup\$
    – Kevin
    Apr 5 at 22:43
  • \$\begingroup\$ 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. \$\endgroup\$
    – Kevin
    Apr 5 at 22:53
  • \$\begingroup\$ That's a good idea, and probably what I'll end up doing (but will try using 10-100 boids to represent each unit) \$\endgroup\$
    – DeeCeptor
    Apr 8 at 16:46


You must log in to answer this question.

Browse other questions tagged .