Documentation
    Preparing search index...

    Function alignment

    • Alignment (§12 flocking): match the neighbours' mean velocity.

      desiredVelocity = clamp((Σ neighbour.velocity) / count, maxSpeed)
      

      The mean velocity is the desired velocity directly — not renormalized to maxSpeed, because a flock cruising at half speed should not be accelerated to full speed by alignment alone. It is clamped to maxSpeed, so an agent is never asked for a velocity it cannot hold. With no neighbours the result is the zero vector (see separation on abstention).

      Applied on its own from rest, alignment drives the agent's velocity to the mean exponentially with a one second time constant (the implicit gain noted at the top of this module), and once matched it produces exactly zero.

      Parameters

      Returns Vector3