playMaker

Author Topic: Troop Formation System - Ideas?  (Read 1308 times)

Farwest

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 63
Troop Formation System - Ideas?
« on: October 05, 2018, 08:46:49 AM »
Hi,
I have a battle system, every unit has a Playmaker brain, they Search&Attack enemies. But having numerous units slow down the game.

I am considering, forming the units in formations (under a Parent object) and instead of putting Search&Attack FSM to each unit, putting the Search&Attack FSM to Parent objects only may reduce the performance issues. It will be like, instead of 100 walking units with FSM brains in the battlefield, there will be 100 units with 5 FSM brains in total. I am sure it will have some good change. 

At this point, I need some guidance with fresh ideas. How should I keep the units in formation (like soldiers in Roman legions or Aircrafts attacking a city in formation), units position themselves, or How I can send Animator commands to all units under Troop parent altogether (When staying, they all get "Idle" command; when walking, they all get "Walk" command; near enemy, only the front row of soldiers get "Fight" animaton command, etc.)

For example, if front row of soldiers leave the formation to attack enemies, I think I need to save position of units under Troop object first, then when they finish their attack duty, they need to use "Move Towards" action to return their original position in the formation.

Also how I can change the formation (like square formation, triangle, or rectangle like we do in Totalwar games), I really wonder. Or at least, when a soldier is missing, rest of the soldiers need to re-form the group and formation should be resized.

This is lots of job, I know. But if you have ideas in any one of them, please throw them to me, thanks.
« Last Edit: October 05, 2018, 08:48:56 AM by Farwest »

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Troop Formation System - Ideas?
« Reply #1 on: October 05, 2018, 09:18:55 AM »
I recommend to use the asset called Behavior Designer, which does things like this. It's not cheap, but considering the hours and nerves you're spending on this, it's almost certainly a good investment. It's also Playmaker compatible (just a word of caution, some actions of Behaviour Designer are named the exact same as Playmaker's default ones in the Action Browser. While not causing any trouble, you can accidentially pick the wrong one).

If you want to do this yourself, I'd first sketch out what you consider a proper unit in your mechanics. For example, you can treat a five-troops band a unit, that move together. It depends on whether specific individuals within that unit matter (e.g. the guy on in top left position can be targeted, whether the unit stays always together in a fixed formation). The five troops are something akin to a health bar: if the health of the unit loses 20%, one troop goes down etc.

Maybe you could create a ghostly commander object, which is invisible, but is a set of waypoints that portray the formation you want. The individual troop gets assigned to (or picks one) of the waypoints. And then "tries" to be as close as possible to it. This depends on how your pathfinding etc works.





Farwest

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 63
Re: Troop Formation System - Ideas?
« Reply #2 on: October 05, 2018, 10:08:35 AM »
Thanks for the tips, I know Behaviour Designer, but I will try to create my own system in this case (I learnt it is easier to create our own with Playmaker than learning a new system everytime, also there are integration problems, email exchange for waiting for support and other limitations always. I am saying this generally, maybe this is not the case for Behaviour Designer, if anybody used, please let us know).

Ghostly Commander object suggestion is interesting. But for units to move with it, it could be difficult to keep them in formation, because I fear they will keep following it as a mob around the commander. However I think it is possible to keep units with some specific distance to commander, and however use of "every-frame" calculation as minimum as possible will be very important.