Skip to main content

Alignment

Makes entities align their velocity with their neighbors' velocities.

AlignmentJob

Internally, the behavior calculates a weighted average of it's neigbhors directions and speeds. The weight of each neighbor is higher the closer it is and the more it is directly in front of the entity. The behavior gives the weighted average direction and weighted average speed. The strength of the behavior grows larger the further the direction and speed are from the averages.

This behavior outputs the following:

  • DesiredDirection - Weighted average direction of neighbors' velocity.
  • DirectionDesire - From MinAngleWeight * DirectionStrength to DirectionStrength as angle between current direction and DesiredDirection goes from StartActivationAngle to 360 degress.
  • DesiredSpeed - Weighted average speed of neighbors' velocity.
  • SpeedDesire - From MinSpeedDiffWeight * SpeedStrength to SpeedStrength as difference between the average speed and current speed divided by MaxSpeed goes from StartSpeedDiffFraction to 1.
  • Priority - Priority (constant)

AlignmentComponent

The main interesting properties to adjust on AlignmentComponent are:

  • Observability
    • DistanceP - Power for shaping the influence of each neighbor based on distance.
    • StartAngle - Above this angle a neighbor's influence on the centroid starts to decrease, below it it's at maximum.
    • AngleP - Power for shaping the influence of each neighbor based on angle.
  • Direction Activation
    • AngleActivationP - Power for shaping the interpolation of DirectionDesire.
    • MinAngleWeight - The minimum DirectionDesire returned will MinAngleWeight * DirectionStrength.
    • StartActivationAngle - Above this angle between entity's direction and the weighted average direction the DirectionDesire starts increase, below it it's MinAngleWeight * DirectionStrength.
  • Speed Activation
    • SpeedDiffActivationP - Power for shaping the interpolation of SpeedDesire.
    • MinSpeedDiffWeight - The minimum SpeedDesire returned will be MinSpeedDiffWeight * SpeedStrength.
    • StartSpeedDiffFraction - The minimum difference between the average speed and current speed divided by MaxSpeed after which the SpeedDesire starts to increase above MinSpeedDiffWeight * SpeedStrength.
  • BaseData
    • MaxDistance - Maximum distance where neighbors will be detected.
    • MaxAngle - Maximum field of view angle where neighbors will be detected.
    • DirectionStrength - Multiplies DirectionDesire.
    • SpeedStrength - Multiplies SpeedDesire.
    • Priority - Priority.