Monday, April 29, 2024
HomeGame Developmentunity - How to implement flexible, deformable shapes?

unity – 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.

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.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments