Documentation
    Preparing search index...

    Function flee

    • Flee (§12): move directly away from target at maxSpeed.

      desiredVelocity = normalize(position − target) · maxSpeed
      

      Flee's desired velocity is always the exact negation of seek's, so from rest the two accelerations are exact componentwise negations. They are not negations of one another at non-zero velocity, and deliberately so: both subtract the same velocity, which is what makes flee brake and reverse hard when the agent is charging at the threat, where a literal −seek() would return nearly zero at exactly the wrong moment. tests/steering.test.ts pins both halves of this.

      Parameters

      Returns Vector3