Skip to content

FormationSystem ​

Inherits: Resource

Places the party members around a target position in a formation (tight, spread, V, line or wedge): calculate_formation_positions answers with a position for every unit, with a base spacing and some randomness. cycle_formation and set_formation change the formation.

Variables ​

FormationTypecurrent_formationFormationType.TIGHT
floatbase_spacing2.0
floatrandomization_factor0.3

Methods ​

Dictionarycalculate_formation_positions( units: Array[Entity], target_position: Vector3, formation_direction: Vector3 )
floatcalculate_spacing( unit_count: int )
voidcycle_formation()
voidset_formation( formation: FormationType )

Enumerations ​

enum FormationType ​

The options of formation type: tight, spread, v shape, line, wedge.

  • TIGHT = 0
  • SPREAD = 1
  • V_SHAPE = 2
  • LINE = 3
  • WEDGE = 4

Variable descriptions ​

FormationType current_formation = FormationType.TIGHT ​

The formation the party takes.

float base_spacing = 2.0 ​

The distance between two members.

float randomization_factor = 0.3 ​

How much the places are shaken so the party does not look like a grid.

Method descriptions ​

Dictionary calculate_formation_positions( units: Array[Entity], target_position: Vector3, formation_direction: Vector3 ) ​

Calculate formation positions for a group of units

float calculate_spacing( unit_count: int ) ​

Calculate spacing based on unit count

void cycle_formation() ​

Toggle between formation types

void set_formation( formation: FormationType ) ​

Set the formation type directly