I'm trying to implement a classic twin-stick controller for a group of physics-based game objects. Here are the rules I'm trying to follow:

  • Agents always stay close to each other within a certain threshold.
  • Moving the left stick moves the entire group in that direction.
  • Moving the group on a collider like a wall will "compress" the group like a ball. Releasing the left stick will make the group recover its "natural" shape.

I tried a few things:

  • Classic steering with cohesion/follow behaviors: This kinda works, but when moving against a sharp corner, a part of the group will move on and separate from the others. Adjusting the steering weights in this scenario produces unnatural results, and the whole thing just feels too "floaty".
  • Softbody simulation: This works pretty well when moving on a corner, but you can really feel the springs between each agent. Again, it just feels wrong as a whole.
  • Box2D joints between each agent: Keeps all the agents tightly packed, but the group feels very rigid.

The solution might be a combination of the previous points, but I'm pretty sure I'm over-thinking this.

  • \$\begingroup\$ Did you ever make progress with this? \$\endgroup\$ Apr 6, 2016 at 18:04
  • \$\begingroup\$ Unfortunately no. Still trying to wrap my head around this. \$\endgroup\$
    – jesta
    Jan 13, 2017 at 19:25
  • 1
    \$\begingroup\$ What is your question? \$\endgroup\$
    – Evorlor
    Jul 10, 2017 at 12:24

2 Answers 2


Use a combination of both soft body and classic steering.

Use a soft body grid (or similar) to figure out the ideal target placement of the agents then have the agents independently try to get to their respective positions within some random organic fuzziness to make it look less perfect/artificial.

The agents may optionally give up if they get too far or can't find a way and bump each other into swapping positions if they're out of order.

With some tweaking (depending on your subjective goal) this should get you to an acceptable movement that fills your requirements.


flocking with independent behavior based on situation, where part of that behavior is broadcast message and part is cascade to nearest neighbor that then informs rest of individuals in the unit.

That way if an order to lose formation is given, 5 feet between men, it broadcasts to rest of unit. If close formation is ordered it broadcast also. That order would not be cascaded by weight by iteration but only set at if based on formation by broadcast.

while if a wall impact created a cascade order procedure, it would be weighted cascade and a move for each unit and move of 'unit center point' that would include positional effect by number of iteration it takes to get the message.

The method to cascade I developed in an app years ago, everyone cascades to neighbor but ignores 'order number 'something'' if it already processed that order, and distance adds to weight of order in cases where you want a smooth transition.(to stop recursion orders are numbered and processed only once per individual)

so if one guy hits wall, he cascades 'move closer' formation message to neighbors, and as it filters outwards, they all cascades to neighbors but only first message reception is processed and is processed by depth of iteration to lessen the effect as further from source.

And each unit has a center point at middle of formation that then deduces there path to best choice location individually while the entire unit is pathed with that center point.

Also can be useful in things like individual morale cascading to other units,awareness or agro cascading, or healing cascading to units with effect that effectively includes distance from first effected unit. It also can be used to determine if a unit needs to change formation to a line for instance when it can not 'closer' and fit through an area. A formation change would be created instead of a modification to location within a formation.

Each formation has a center point, and each individual has a dfcp (distance from center point) for the formation(no situation) and a dfcp modification value based on situation where any individual encounter a collision or event. Then units path to that modified location and it changes when any unit collides or stops colliding. The (no situation) values are set by the units choice of formation. And the entire unit is moved by pathing the center point, while each unit paths based on there dfcp offset of that center point.

It is possible to use broadcast all in non weighted events, but the 8 neighbor broadcast method allows for different depths based on iteration count.

Although that code was stolen from me years ago and I have not been compensated.

think of this as explanation of center point, and shadow as broadcast and cascade pipes to neighbors. You only have to walk the center point, while the individuals calculate distance from that center point, and entire unit will still react to events effecting unit on other side of formation while still maintaining independent actions.

Green Day - Boulevard of Broken Dreams https://www.youtube.com/watch?v=Soa3gO7tL-c

And cascade can also be used to fill front line ranks if units are damaged, routed or killed.

thinking back on the original design I wrote, some of the other uses is that a single independent unit, can get full unit status by what messages it receives from different individuals through the cascade or broadcast, and can be used to get healers to start casting group heals, or generals to call in back up cavalry, or various other full unit actions based on individual states within the unit.

So while setting position and agro, the healer unit is also receiving detailed information of damage and morale information from each unit as the individual units broadcast or cascade state.

And the general unit is paying attention to the states of individuals damage and morale, and can order front line rotations after collision with enemy in combat and some distress situation from a morale or damage cascade or broadcast.

Any message that should inform every unit equally is full broadcast, any message that should have a distance component is cascaded.

cascade messaging is also shown in this movie, although you would have to know about glyphs in the sand. https://www.youtube.com/watch?v=mdT163r3dUQ

  • 1
    \$\begingroup\$ I'm not sure I understand the relevance of the Green Day clip, but thanks. \$\endgroup\$
    – jesta
    Apr 10, 2015 at 14:35
  • \$\begingroup\$ if you do use cascade messaging, by iterating you get the wave effect over time, according to distance, that itteration for first posting is all 8 surrounding units, but after that. A unit informed from left, only needs to inform right, unit informed from bottom only needs to inform top, and a diagnol inform only needs inform 3 around corner on other side of diagnol to get full unit coverage. \$\endgroup\$ Apr 10, 2015 at 19:26
  • \$\begingroup\$ For non guaranteed geometric grid assignments of unit location multiD linked lists of units recursion checking by full 8 cascade is necessary, or in the cases where some units may be missing or non responsive. \$\endgroup\$ Apr 10, 2015 at 19:34
  • \$\begingroup\$ As far as the song, he is discussing independent movement within a unit, and attribute of Nut (response of refusal to surrender from unit in ww2) while communicating to other units through shadow pipes(songs) Similar to a neural net process. \$\endgroup\$ Apr 10, 2015 at 19:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .